View Full Version : Combo box returning 3 prepolutated value for 1 choice

04-03-2011, 02:41 PM
Hello there

I am working on a multiple combo box setting with a selection by
City/Airport code

One the 3 first choice are made I would like the code to return automatically to the box number 4 , 5 and 6 a given pre defined value
For instance
1st Choice USA
2nd Choice JFK
3rd Choice New York

Combo box 4 will return the price of a taxi
Combo box 5 will return the price of a Limo
Combo box 6 will return the price of a Coach

Below is the code I use, can someone help please ?

<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("Spain", "-");
data_2 = new Option("France", "-");

// second combo box

data_1_1 = new Option("MALAGA", "-");
data_1_2 = new Option("BARCELONA", "-");
data_2_1 = new Option("PARIS", "--");
data_2_2 = new Option("NICE", "--");
data_2_3 = new Option("23", "--");
data_2_4 = new Option("24", "--");
data_2_5 = new Option("25", "--");

// third combo box

data_1_1_1 = new Option("PUERTO BANUS", "*");
data_1_1_2 = new Option("FUENGIROLA", "*");
data_1_1_3 = new Option("BENALMADENA", "*");
data_1_2_1 = new Option("LLORET", "*");
data_1_2_2 = new Option("SANTA SUZANNA", "*");
data_1_2_3 = new Option("LA PINEDA", "*");
data_1_2_4 = new Option("124", "*");
data_2_1_1 = new Option("PARIS", "**");
data_2_1_2 = new Option("DISNEYLANND", "**");
data_2_2_1 = new Option("NICE ", "**");
data_2_2_2 = new Option("MONACO", "**");
data_2_3_1 = new Option("231", "***");
data_2_3_2 = new Option("232", "***");

// fourth combo box
data_1_1_1_1 = new Option("15", "*");
data_1_1_2_1 = new Option("16 GBP", "*");
data_1_1_3_1 = new Option("28 GBP", "*");
data_1_2_1_1 = new Option("130 GBP", "*");
data_1_2_2_1 = new Option("440 GBP", "*");
data_1_2_3_1 = new Option("550 GBP", "*");
data_1_2_4_1 = new Option("38 GBP", "*");
data_2_2_1_1 = new Option("17 GBP","%")
data_2_2_1_2 = new Option("18 GBP","%%")

// fifth combo box
data_1_1_1_1_1 = new Option("16", "*");

// sixth combo box
data_1_1_1_1_1_1 = new Option("18", "*");

// 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,_4,_5,_6,_7 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;


<select name="combo0" id="combo_0" onChange="change(this);" style="width:200px;">
<option value="value1">Select Country</option>
<option value="value2">Spain</option>
<option value="value3">France</option>

<select name="combo1" id="combo_1" onChange="change(this)" style="width:200px;">
<option value="value1">Select Airport</option>
<select name="combo2" id="combo_2" onChange="change(this);" style="width:200px;">
<option value="value1">Select Resort</option>
<select name="combo3" id="combo_3" onChange="change(this);" style="width:200px;">
<option value="value1">Shuttle Cost</option>

<select name="combo4" id="combo_4" onChange="change(this);" style="width:200px;">
<option value="value1">Private Transfer 4 pax cost</option>

<select name="combo5" id="combo_5" onChange="change(this);" style="width:200px;">
<option value="value1">Private transfere 8 pax cost</option>

<select name="combo6" id="combo_6" onChange="change(this);" style="width:200px;">
<option value="value1">Coach transfer</option>



<p align="center">This free script provided by<br />
<a href="http://javascriptkit.com">JavaScript

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum