[thelist] javascript newbie need a hand

Joshua Olson joshua at waetech.com
Tue May 28 08:21:01 CDT 2002


----- Original Message -----
From: "[Gauthier at PlacidSound]" <gauthier at placidsound.com>
Sent: Tuesday, May 28, 2002 6:26 AM


> so two questions:
>     -how can I set the elm.onclick property (should I call it a
property???) to call the oposite function?
>     -how can I avoid onclick event of parents elements (try clicking on a
submenu item)

As for the second question, you could make a new function:

function toggleChilds(elm)
{
 for(var i=0; i<elm.childNodes.length; i++)
 if(!elm.childNodes[i].length)
   if (elm.childNodes[i].style.display=="")
     elm.childNodes[i].style.display="none";
   else
     elm.childNodes[i].style.display="";
  event.cancelBubble = true;
}

Call this function from your onclick handlers instead of hideChilds or
showChilds.  Basically, this one determines the needed changed (hide or
show) based on their current state.  There are a few other ways to
accomplish this same functionality.  If you are curious, you could search
for "expanding menu tutorial" on google and get enough links to answer most
of your foreseeable questions.

HTH,
-joshua





More information about the thelist mailing list