View Full Version : "Multiple Dynamic Combo Boxes" configuration

02-29-2012, 06:24 PM

I'm using "Cut & Paste Multiple Dynamic Combo Boxes (http://www.javascriptkit.com/script/script2/multiplecombo.shtml)" script. I want to configure it, so at first only 1st combo box is visible and the rest are hidden and only populate based on the selections. Also, when the last parameter (from the 5th combo box) was selected, I need to show the table with the search results based on the all selected parameters.

Here is what I have so far:

<script language="JavaScript" type="text/javascript">

*** Multiple dynamic combo boxes
*** by Mirko Elviro, 9 Mar 2005
*** Script featured and available on JavaScript Kit (http://www.javascriptkit.com)
***Please do not remove this comment

// This script supports an unlimited number of linked combo boxed
// Their id must be "combo_0", "combo_1", "combo_2" etc.
// Here you have to put the data that will fill the combo boxes
// ie. data_2_1 will be the first option in the second combo box
// when the first combo box has the second option selected

// first combo box

data_1 = new Option("1", "$");

// second combo box

data_1_1 = new Option("11", "-");
data_1_2 = new Option("12", "-");
data_1_3 = new Option("13", "-");

// third combo box

data_1_1_1 = new Option("111", "*");
data_1_2_1 = new Option("121", "*");
data_1_3_1 = new Option("131", "*");

// fourth combo box

data_1_1_1_1 = new Option("1111","%")
data_1_1_1_2 = new Option("1112","%")
data_1_2_1_1 = new Option("1211","%")
data_1_3_1_1 = new Option("1311","%")
data_1_3_1_2 = new Option("1312","%")
data_1_3_1_3 = new Option("1313","%")

// fifth combo box

data_1_1_1_1_1 = new Option("11111","%")
data_1_1_1_1_2 = new Option("11112","%")
data_1_1_1_2_1 = new Option("11121","%")
data_1_1_1_2_2 = new Option("11122","%")
data_1_1_1_2_3 = new Option("11123","%")
data_1_1_1_2_4 = new Option("11124","%")
data_1_2_1_1_1 = new Option("12111","%")
data_1_3_1_1_1 = new Option("13111","%")
data_1_3_1_2_1 = new Option("13121","%")
data_1_3_1_2_2 = new Option("13122","%")
data_1_3_1_2_3 = new Option("13123","%")
data_1_3_1_2_4 = new Option("13124","%")
data_1_3_1_2_5 = new Option("13125","%")
data_1_3_1_3_1 = new Option("13131","%")
data_1_3_1_3_2 = new Option("13132","%")

// other parameters



function change(currentbox) {
numb = currentbox.id.split("_");
currentbox = numb[1];


// I empty all combo boxes following the current one

while ((eval("typeof(document.getElementById(\"combo_"+i+"\"))!='undefined'")) &&
(document.getElementById("combo_"+i)!=null)) {
son = document.getElementById("combo_"+i);
// I empty all options except the first one (it isn't allowed)
for (m=son.options.length-1;m>0;m--) son.options[m]=null;
// I reset the first option
son.options[0]=new Option(displaywhenempty,valuewhenempty)

// now I create the string with the "base" name ("stringa"), ie. "data_1_0"
// to which I'll add _0,_1,_2,_3 etc to obtain the name of the combo box to fill

while ((eval("typeof(document.getElementById(\"combo_"+i+"\"))!='undefined'")) &&
(document.getElementById("combo_"+i)!=null)) {
if (i==currentbox) break;

// filling the "son" combo (if exists)


if ((eval("typeof(document.getElementById(\"combo_"+following+"\"))!='undefined'")) &&
(document.getElementById("combo_"+following)!=null)) {
son = document.getElementById("combo_"+following);
while ((eval("typeof("+stringa+i+")!='undefined'")) || (i==0)) {

// if there are no options, I empty the first option of the "son" combo
// otherwise I put "-select-" in it

if ((i==0) && eval("typeof("+stringa+"0)=='undefined'"))
if (eval("typeof("+stringa+"1)=='undefined'"))
eval("son.options[0]=new Option(displaywhenempty,valuewhenempty)")
eval("son.options[0]=new Option(displaywhennotempty,valuewhennotempty)")
eval("son.options["+i+"]=new Option("+stringa+i+".text,"+stringa+i+".value)")
while (cstatus[i]!=null) {
return combostatus;


<table style="width: 49%">
<td style="width: 200px">Option 1:</td>
<td style="width: 213px">
<select name="combo0" id="combo_0" onChange="change(this);" style="width:200px;">
<option value="none">-select-</option>
<option value="1">1</option>
<td style="width: 200px">Option 2:</td>
<td style="width: 213px">
<select name="combo1" id="combo_1" onChange="change(this)" style="width:200px;">
<option value=""> </option>
<td style="width: 200px">Option 3:</td>
<td style="width: 213px">
<select name="combo2" id="combo_2" onChange="change(this);" style="width:200px;">
<option value=""> </option>
<td style="width: 200px">Option 4:</td>
<td style="width: 213px">
<select name="combo3" id="combo_3" onChange="change(this);" style="width:200px;">
<option value=""> </option>
<td style="width: 200px">Option 5:</td>
<td style="width: 213px">
<select name="combo4" id="combo_4" onChange="change(this);" style="width:200px;">
<option value=""> </option>

This script is used in my html page and I don't have a database to choose from. So, I wonder if it's possible to make all these modifications with only html and JavaScript. Any help will be appreciated.

Thanks in advance.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum