[Javascript] <select>

Rodney Myers rodney at aflyingstart.net
Wed Sep 4 08:40:20 CDT 2002


document.formName.selectName.options[x].value = 'test';

formName is name of form (or use forms array)
selectName  is name of select (or use elements array)
options is array of options in that select
x is the number of the option you wish to fill (which may not yet exist)

You may also have to manipulate
document.formName.selectName.options.length

And if you want "test" to appear in the select you would need to write
document.formName.selectName.options[x].text = 'test';

hth

Rodney

Iztok Polanic wrote:

> Hi!
>
> How to fill a <select> box?
> I tried this but it doesn't work:
>
> document.forms["FORMA"].elements["SELECT"].value = 'test';
>
> Bye,
>
> Iztok
>
>





More information about the Javascript mailing list