473,383 Members | 1,821 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

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

Similar topics

5
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...
13
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...
3
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
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...
4
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...
1
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,...
5
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:...
1
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...
1
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....
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.