473,569 Members | 2,459 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 6074
"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.u k (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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
35126
by: cedawe | last post by:
I have two select boxes. When the user picks a value in the first one it completely re-populates the second one. It works fine, but only generates a standard OPTIONS list and I now want to group the options using OPTGROUPs. <select name="Selector1" size="1" onchange="reload2(this.options.selectedIndex, document.Form1.Selector2)">...
13
2876
by: mr_burns | last post by:
hi, is it possible to change the contents of a combo box when the contents of another are changed. for example, if i had a combo box called garments containing shirts, trousers and hats, when the user selects shirts another combo box called 'size' would contain sizes in relation to shirts (ie. chest/neck size). the same would occur for...
3
4295
by: vgrssrtrs | last post by:
<html> <head> <script language="JavaScript"> <!-- /* *** Multiple dynamic combo boxes *** by Mirko Elviro, 9 Mar 2005 *** ***Please do not remove this comment
2
1967
by: taras.di | last post by:
Hi everyone, I've been reading up on how to create a drop down box who's context is dynamically produced based on the value of a previous select box. I've read a lot about some of the browsers not properly readjusting the width of a dynamically produced drop down box, and some browsers having problems adjusting the height and widths (most...
4
2132
by: PM ArunKumar | last post by:
i have two dropdown list in my form where the values in the list of second drop down changes based on the value i select in the first dropdown.(very similar to country and states list), here after submitting the form, if i go back the value which i selected in my second dropdown list doesn't appear. for eg: if select USA and virginia ,when i go...
1
3741
by: skyson2ye | last post by:
Hi, guys: I have written a piece of code which utilizes Javascript in PHP to create a three level dynamic list box(Country, States/Province, Market). However, I have encountered a strange problem, and I have spent three days trying to debug but to no avail. Everything is OK when there are only two dependent list boxes, but when adding the...
5
1452
by: judyw | last post by:
I am trying to build a form with many options depending on each other. I purchased a script called dynamic list options with which I create arrays of options that populate select boxes like this: <select name="productSwags" onChange="PopulateOptions(this, 'productFabric');"> I can also create arrays like this: var Array4 = new...
1
3453
by: bytesFTW99 | last post by:
I have been struggling with this for some time can anyone help out? just trying to have 3 dropdown boxes that fill depending on what is selected, then in some cases click a button and have the second set of 3 dropdown boxes be filled with the same values. thank you <head> <SCRIPT LANGUAGE="JavaScript" type="text/javascript"> var...
1
2947
by: jmartmem | last post by:
Greetings, I have a nagging problem with client-side dynamic dependent list boxes that perhaps someone can help me troubleshoot. I have a form with a series of dynamic dependent list boxes. Making a selection from list/box A (Qtr) selects a fiscal quarter, which then refreshes the values in list/box B (Mth), which shows the 3 months in that...
0
8132
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7678
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7982
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6286
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5514
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5222
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3656
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3644
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1226
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.