PDA

View Full Version : dynamic dependent drop down lists


texter
06-18-2003, 02:45 PM
Hi,
I have two list boxes , the second one gets dynamically changed based on the first ones values.
This is in a classic asp, vbscript page.
When I submit the page , how do i retain the values selected in both boxes.
Here is the script....


<script type="text/javascript">
// Create arrays containing manually enter,auto enter lists
// Note: These arrays could be created dynamically


var faremodeselect,automodeselect,NumEntries, i;


var arrfaremode, arrOWplusRT, arrOWonly, arrRTonly;
arrOWplusRT = []
arrOWonly = ["RoundTrip Fares (Multiply OW by 2"]
arrRTonly = ["Oneway Fares (Divide RT by 2"]
arrfaremode =[ arrOWonly, arrRTonly,arrOWplusRT]







// Function to handle dynamically altering the contents of the Auto Enter List box
function handleChange(newDisplay, newVal)
{
faremodeselect = document.myForm.faremode
automodeselect = document.myForm.automode




// Delete all entries in the automode list box
for (i = automodeselect.length; i > 0; i--)
{
automodeselect.options[i-1] = null
}



// Add comment option to automode List box
automodeselect.options[0] = new Option("OFF",0)



// If faremode is selected add its automode to the automode List box



if (newDisplay >= 0)
{
NumEntries = arrfaremode[newDisplay].length
for (i = 1; i <= NumEntries; i++)
{
automodeselect.options[i] = new Option((arrfaremode[newDisplay])[i-1],(i))
}
}
automodeselect.selectedIndex = newVal


}


</script>