Re: What's wrong with my Javascript? -
07-17-2003
, 10:58 AM
Thanks David,
I've tried the modifications you suggested, but to no avail. I updated the function to use the equality operator, and removed all the underscores from my class names, but it doesn't seem to make any difference.
I've modified the function a bit:
function toggleSubMenu(submenu) {
if(submenu.className=='submenuoff') {
openMenu(submenu)
} else {
closeMenu(submenu)
}
}
function openMenu(submenu) {
submenu.className='submenuon'
}
function closeMenu(submenu) {
submenu.className='submenuoff'
}
....basically just to test whether I'm going about the swap the right way. If I call OpenMenu or CloseMenu directly (onMouseOver for example) the menu works exactly as expected.
When I call toggleSubMenu onClick, the menu will expand as expected. Then when I click a second time, nothing happens - no error, just nothing. Does this mean that the if...else is not right?
I've tried adding a second 'if' after the else, just to be sure, but no joy. I've also tried using the submenu's ID and referencing with getElementById in the functions, no good either...
Any ideas? I'm trying to put together an URL I can point you to, but I haven't got an app server to run the dynamic stuff live yet... This is starting to bug me!
Thanks for your help - much appreciated.
Ben |