473,395 Members | 1,969 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,395 software developers and data experts.

Populating Selectbox

I have 2 selectboxes and I want to change the values in the second
based on the first one. I found a few examples of this but none of
them quite do what I want. Could someone get me started on this or
point me to an example? Thanks

Box 1:

<SELECT name="ddlAvailable">
<option value="A,B,C,D,E">All Sections</option>
<OPTION VALUE = "A,B,C">A,B,C</Option>
<OPTION VALUE = "A">A</Option>
<OPTION VALUE = "D,E">D,E</Option>
<OPTION VALUE = "F">F</Option>
</SELECT>
Box 2:

If 'All Sections' is selected in ddlAvailable then

<SELECT name="ddlSelected">
<option value="A">Section A</option>
<option value="B">Section B</option>
<option value="C">Section C</option>
<option value="D">Section D</option>
<option value="E">Section E</option>
</SELECT>

If 'A,B,C' is selected in ddlAvailable then

<SELECT name="ddlSelected">
<option value="A">Section A</option>
<option value="B">Section B</option>
<option value="C">Section C</option>
</SELECT>

If 'A' is selected in ddlAvailable then

<SELECT name="ddlSelected">
<option value="A">Section A</option>
</SELECT>

etc..

Nov 16 '06 #1
1 1516
ASM
ev*******@gmail.com a écrit :
I have 2 selectboxes and I want to change the values in the second
based on the first one. I found a few examples of this but none of
them quite do what I want. Could someone get me started on this or
point me to an example? Thanks
function newSelect() {
// give here name (not id) of your form :
var f = document.forms['theForm'];
var dad = f.ddAvaiilable;
var son = f.ddlSelected;
var k = dad.selectedIndex;
var val = dad.options[k].value.split(',');
son.length = 0;
for(var i=0; i<val.length; i++)
{
var o = new Option(val[i], 'Section '+val[i]);
son[son.length] = o;
}
}

<SELECT name="ddlAvailable">
<SELECT name="ddlAvailable" onchange="newSelect();">
<option value="A,B,C,D,E">All Sections</option>
<OPTION VALUE = "A,B,C">A,B,C</Option>
<OPTION VALUE = "A">A</Option>
<OPTION VALUE = "D,E">D,E</Option>
<OPTION VALUE = "F">F</Option>
</SELECT>


--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Contact : http://stephane.moriaux.perso.wanadoo.fr/contact
ASM = Aimable Stéphane Moriaux = Amateur Sasseur Merdouilles
Nov 16 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Tole | last post by:
hi all, i've got a selcetbox (multiple) which is filled by javascript. only problem is that i have aprox 1000 options to add to that select, and that adding lasts for 5-6 seconds. Even...
5
by: bigbuddha | last post by:
Hello, I have a form two multiple selectboxes. Firs one with options, second one empty I need to select a few items and hit an "add" button to get them in the second one. Preferably a "remove"...
7
by: Erwin Moller | last post by:
Hi, situation: I have a long list of options in multiple selectbox. The selectbox gets a scrollbar in that situation. Does anybody know if it is possible to scroll through the options with...
3
by: Stefan Richter | last post by:
I would like to fill a Selectbox dynamically. I am taking all values from a db, and fill them into a selectbox. I guess the best way was to use some kind of a dynamical array, where you don't have...
4
by: shankwheat | last post by:
I'm passing a string like 'Div3,Div4' to use as options in a selectbox but I need the text the user sees in the box different from the values. My code populates the values in the selectbox...
4
by: evanburen | last post by:
I have a bi-dimensional array that looks like this. I could split this up any I need to if there is a better method. {1,COMS}{2,IBM}{3,F} I want to use this array to populate a selectbox. The...
1
by: mamidira | last post by:
I had 3 select boxes in my form where all the 3 are dependent on the above select box. i.e., the values in the second select box is dependent on the selection of the first selectbox and same with...
1
by: giloosh | last post by:
i would like to dynamically output such a selectbox below using php and mysql: <select> <option< 100 </option> <option100 to 150 </option> <option150 to 200 </option> <option200 to 250...
3
by: =?iso-8859-1?q?Jesper_R=F8nn-Jensen?= | last post by:
I'm working with a requirement to make a selectbox the same height as normal text input elements. (at least for IE7) But in IE the selectbox reacts strangely to the CSS rules. Normally, there...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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,...

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.