Click to See Complete Forum and Search --> : Changing styles with Javascript


Wildcat
01-28-2004, 09:52 AM
I'm trying to cut down on the page space one of my link menus takes up, so I tried to write a code that would only display the itemized links if I click on the main one. I keep getting script errors, and would appreciate any help.

My test style:

#test {visibility: hidden; display: none;}


My attempt at Javascript (just the open function to make it easier to read):

function openMenu(lookit) {
if((document.getElementById)&&(document.getElementById(lookit).style.visibility = "hidden")) {
document.getElementById(lookit).style.visibility = "visible";
document.getElementById(lookit).style.display = "block";
}
elseif((document.all)&&(document.all[lookit].style.visibility = "hidden")) {
document.all[lookit].style.visibility = "visible";
document.all[lookit].style.display = "block";
} }


And lastly, the call to the function itself:

<li><a href="javascript:openMenu('test');">Test</a></li>
<div id="test"><ul>
<li>one</li>
<li>two</li>
<li>three</li>
</ul></div>

Wildcat
01-28-2004, 09:53 AM
Er, ignore the image tag in the last part. I think that happened when I was previewing the code. it's supposed to read openMenu