HighDots Forums  

Re: Variable Substitution

Javascript JavaScript language (comp.lang.javascript)


Discuss Re: Variable Substitution in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Ivo
 
Posts: n/a

Default Re: Variable Substitution - 05-12-2004 , 10:02 AM






"Dennis Marks" asked
Quote:
In the following function:

function showMenu(theMenu, theAction) {
if (document.getElementById)
{document.getElementById(theMenu).style.visibility = theAction;}
else {if (document.layers) {document.theMenu.visibility = theAction;}
else {document.all.theMenu.style.visibility = theAction;}}
}

Will the passed value of theMenu be substituted in the last 2 lines or
will it use "theMenu" as the value?
The latter.

Quote:
Do I have to use the following:
eval("document.all."+theMenu+".style.visibility")
No. Try document.all[theMenu].style.etc.
with square brackets, no eval and no quotes.
HTH
Ivo




Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.