469,579 Members | 1,098 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,579 developers. It's quick & easy.

dynamic options in select boxes?

Hi,

I need to have two <SELECT> boxes: "brand" and "model". The user should
first select brand. Then the other select box should contain the options
dependend of what user chose in "brand". I figure this is something with
making some arrays containing models or something. Do any of you have an
example of how this can be done? I have tried to google for it, but dont
really know what to search for, so I get lousy results :(

--
Yours
Thomas Damgaard
Jul 20 '05 #1
2 5990
"Thomas Damgaard" wrote on 13/11/2003:
Hi,

I need to have two <SELECT> boxes: "brand" and "model". The user should first select brand. Then the other select box should contain the options dependend of what user chose in "brand". I figure this is something with making some arrays containing models or something. Do any of you have an example of how this can be done? I have tried to google for it, but dont really know what to search for, so I get lousy results :(


SELECT elements (represented by a Select object) have a property
called 'options'. This is an array that contain Option objects and
represents the options listed by the SELECT element. You can create
Option objects using the 'new' keyword and then append them to the
Select object on your page:

document.myForm.myMenu.options[ document.myForm.myMenu.length ] = new
Option ( 'option-text', 'option-value' );

If you want to re-build a Select menu completely, you can set the
'length' property of the 'options' array to zero.

document.myForm.myMenu.options.length = 0;

Look for information on the Select and Option objects. Try here:
http://devedge.netscape.com/library/...1.3/reference/
It warns that v1.3 is obsolete (it is), but I haven't finished reading
about the Document Object Model (DOM) used by more recent versions,
and v1.3 is still supported, anyway.

Mike

--
Michael Winter
M.Winter@[no-spam]blueyonder.co.uk (remove [no-spam] to reply)
Jul 20 '05 #2
Michael Winter wrote:
SELECT elements (represented by a Select object) have a property
called 'options'. This is an array that contain Option objects and
represents the options listed by the SELECT element. You can create
Option objects using the 'new' keyword and then append them to the
Select object on your page:

document.myForm.myMenu.options[ document.myForm.myMenu.length ] = new
Option ( 'option-text', 'option-value' );

If you want to re-build a Select menu completely, you can set the
'length' property of the 'options' array to zero.

document.myForm.myMenu.options.length = 0;

Look for information on the Select and Option objects. Try here:
http://devedge.netscape.com/library/...1.3/reference/
It warns that v1.3 is obsolete (it is), but I haven't finished reading
about the Document Object Model (DOM) used by more recent versions,
and v1.3 is still supported, anyway.


Ok.
Thanks!
--
Med venlig hilsen
Thomas Damgaard
Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by cedawe | last post: by
13 posts views Thread by mr_burns | last post: by
3 posts views Thread by vgrssrtrs | last post: by
2 posts views Thread by taras.di | last post: by
5 posts views Thread by judyw | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.