[Greasemonkey] Drop down box

Johan Sundström oyasumi at gmail.com
Sat Sep 23 21:32:14 EDT 2006


On 9/22/06, Tod Beardsley <todb at planb-security.net> wrote:
> So, since I took this as a challenge, I've updated it to a one liner.
>
> Install here: http://www.planb-security.net/userscripts/delicious-default-bookmarks.user.js
>
> But it's just:
>   document.forms[0].elements[2].selectedIndex = 0;
>
> You don't know exactly what form you're modifying, or to what value,
> but it's fast and easy to read. Should be fine since I don't expect
> the form to move around too much in the next few months.

It's usually a safer bet to only assume node id:s remain constant;
forms do change from time to time, especially in the number and order
of elements. If or when the above stops working,
document.getElementById('searchtype').selectedIndex = 0; probably
still will.

-- 
 / Johan Sundström, http://ecmanaut.blogspot.com/


More information about the Greasemonkey mailing list