> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Wendy Smoak
> Sent: Monday, February 16, 2004 11:31 AM

> can someone explain (or add 
> comments to) this, taken from tabs.js:
> 
> function initMenu() {
>     var menu = document.getElementById("menuList");
>     var items = menu.getElementsByTagName("li");
>     for (var i=0; i < items.length; i++) {
>         items[i].firstChild.myIndex = i;
>         items[i].firstChild.onclick=function() {
>             setCookie("menuSelected", this.myIndex);
>             };
>     }
>     activateMenu();
> }
> 
> It looks like it's adding an onclick handler to every menu, like this:
>    <div id="menuDiv"><ul id="menuList">
>       <li><a href="balanceSheet.do" title="Standard" 
> onclick="setCookie('menuSelected',0);">Standard</a></li>
>       <li><a href="?mode=Advanced" title="Advanced" 
> onclick="setCookie('menuSelected',1);">Advanced</a></li>
>    </ul></div>

Yes, that's what it's doing.  The myIndex is an attribute that is set to
the value of "i" and then used later.  Here's the problem I experienced
and the reason it's done this way:

http://www.experts-exchange.com/Web/Web_Languages/JavaScript/Q_20634050.
html

> 
> But what is the 'myIndex' part?  (Seems like you're adding an 
> arbitrary attribute to some tag?)  Then when you get to 
> calling setCookie, what is 'this' (and how do you know)?

'this' represents the <li> that's getting clicked on.

> 
> I need a big poster of all the elements and what attributes 
> they have! Google was uncooperative, does such a thing exist? 
>  (Once upon a time I had a UML diagram of Struts as my 
> desktop wallpaper.)
> 
> -- 
> Wendy Smoak
> 
> 
> 
> -------------------------------------------------------
> SF.Net is sponsored by: Speed Start Your Linux Apps Now.
> Build and deploy apps & Web services for Linux with
> a free DVD software kit from IBM. Click Now! 
> http://ads.osdn.com/?ad_id=1356&alloc_id=3438> &op=click
> 
> _______________________________________________
> 
> struts-menu-user mailing list
> [EMAIL PROTECTED] 
> https://lists.sf.net/lists/listinfo/struts-> menu-user
> 




-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
_______________________________________________
struts-menu-user mailing list
[EMAIL PROTECTED]
https://lists.sf.net/lists/listinfo/struts-menu-user

Reply via email to