views:

12

answers:

1

I'm writing a firefox extension and I have a menulist of links that should be automatically (upon load) set to the last link it was set before I closed it. It just keep being set to the first menu item. I've tried using setAttribute('selectedIndex', 1), but that doesn't work. What am I doing wrong?

Some sample code:

<menulist>
 <menupopup>
   <menuitem label="default"/>
   <menuitem label="I want this one to be selected" />
   <menuitem label="Or this one." />
 </menupopup>
</menulist>
A: 

Set the selectedIndex property, not the attribute.

document.getElementById("mymenulistid").selectedIndex = 1;

After adding it to the document you usually need to edit properties for things like this.

pc1oad1etter
Thanks, that makes perfect sense. Didn't know they doubled as properties. Now I know.
Clayton Gray