I would suggest giving the tag an identical id attribute, then using the
getElementById() function to get it, thusly:
<select name="born-year" id="born-year">
blah....
</select>
.....
.....
document.getElementById("born-year").selectedIndex = 0;
Using this method, you can directly access any id'd object in your page,
whether it's in a form or not. Obviously this means that if you have two
similar forms, they can't share identically named tags.
HTH,
P.
"Sandman" <mr@sandman.net> wrote in message
news:mr-0E2F56.10311103092003@news.fu-berlin.de...[color=blue]
> I have a input like this:
> <select name="born-year">
>[list of years]
> </select>
>
> And I want to set this input to the first in selectedIndex, which usually[/color]
is[color=blue]
> done by
>
> document.form.input.selectedIndex = 0
>
> But this won't work:
>
> document.form.born-year.selectedIndex = 0
>
> Probably because it has a '-' in it's name, right? How do I do it?
>
> --
> Sandman[.net][/color]
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (
http://www.grisoft.com).
Version: 6.0.514 / Virus Database: 312 - Release Date: 28/08/2003