Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

tricky js question

Status
Not open for further replies.

801119

Programmer
Apr 10, 2000
311
SE
if I have this html code:
<span id=&quot;folder1&quot;> hello 1 </span>
<span id=&quot;folder2&quot;> hello 2 </span>
<span id=&quot;folder3&quot;> hello 3 </span>
<a href=&quot;JavaScript:show(1)&quot;>Show / hide 1</a>
<a href=&quot;JavaScript:show(2)&quot;>Show / hide 2</a>
<a href=&quot;JavaScript:show(3)&quot;>Show / hide 3</a>

how do I simpliest write the JS code?
this is what I know, (dummy code)
folder1.style.visibility = &quot;visible&quot;;
but how do I use something like this
folder[num].style.visibility = &quot;visible&quot;; ???
My codes look like something a kid wrote
I have absolutely no idea what I am talking about
Somehow I still manage to make it work
 
Try:
function show(num) {
fld = eval(&quot;folder&quot; + num);
fld.style.visibility = &quot;visible&quot;;
}
Jessica [ponytails2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top