Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

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


Comment on Re: Possible to refer to variable defined later in script?
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1003518]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (6)
As of 2015-07-03 20:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (56 votes), past polls