Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re: Possible to refer to variable defined later in script?

by NetWallah (Abbot)
on Nov 12, 2012 at 22:55 UTC ( #1003518=note: print w/replies, xml ) Need Help??

in reply to Possible to refer to variable defined later in script?

I have had a similar design issue in the past - at that time, what I did was to create an empty <DIV> element at the top, then populate it later in the page using perl-generated javascript code that referenced the DIV.

update: Here is the Javascript function I called to update the DIV text:

function replaceText(sId, sText) { var el; if (document.getElementById && (el = document.getElementById(sId))) { while (el.hasChildNodes()) el.removeChild(el.lastChild); el.appendChild(document.createTextNode(sText)); } }
In my case, the ID belonged to a <td> element of a CGI generated table:
td({-id=>'SPECIALNAME_' . $g->Identifier},'N/A'), # The 'N/A' gets r +eplaced

             "By three methods we may learn wisdom: First, by reflection, which is noblest; Second, by imitation, which is easiest; and third by experience, which is the bitterest."           -Confucius

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1003518]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (7)
As of 2017-02-20 07:14 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (294 votes). Check out past polls.