Page 1 of 1

javascript display menu stall on first onclick

Posted: Wed Jun 04, 2003 5:00 pm
by kendall
Hello,

the following is a script that checks a div tag for its display attribute and sets it the opposite

function menu(id)
{
temp_Obj = attach(id);
element = temp_Obj.style.display;
if(element == 'none'){
temp_Obj.style.display = 'inline';
}else{
temp_Obj.style.display = 'none';
}
}

but on the first onClick = menu('submenu') it doesnt do any thing(divs are set to done by default css)
however on a second attempt it will

Whats wrong?

Kendall

Posted: Thu Jun 05, 2003 3:25 am
by Wayne
set the style tag in the div when you write/output the code, otherwise it first has to set up the style before it can changes, which is probably why when you clikc it the first time nothing happens but if you click it again it works.