"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)