LuigiX
10-12-2003, 06:13 PM
Hi
I have the following functions which take values from one dropdown and display values in the dependent dropdown based on the first dropdown. This works well except the number is being passed to the form on submit instead of the name thus.
"Form Confirmation
Manager_Delegate: 1
Completed_By: 1"
The code for the two dropdowns in the body is:
<SELECT id=Manager_Delegate name=Manager_Delegate onchange="selectChange(this, employmentForm.secondChoice, arrItems1, arrItemsGrp1);">
<option value=0 SELECTED>
<option value=1>Manager</option>
<option value=2>Delegate</option>
</select>
<select id=secondChoice name="Completed_By">
</select></td>
The functions are:
<!-- Begin
var arrItems1 = new Array();
var arrItemsGrp1 = new Array();
arrItems1[1] = "Jo Bloggs";
arrItemsGrp1[1] = 1;
arrItems1[2] = "Henry Paul";
arrItemsGrp1[2] = 1;
arrItems1[3] = "Henry Ford";
arrItemsGrp1[3] = 2;
arrItems1[4] = "Jeff Blink";
arrItemsGrp1[4] = 2;
function selectChange(control, controlToPopulate, ItemArray, GroupArray)
{
var myEle ;
var x ;
// Empty the second drop down box of any choices
for (var q=controlToPopulate.options.length;q>=0;q--) controlToPopulate.options[q]=null;
if (control.name == "Manager_Delegate") {
}
// ADD Default Choice - in case there are no values
myEle = document.createElement("option") ;
myEle.value = 0 ;
//myEle.text = "[SELECT]" ;
controlToPopulate.add(myEle) ;
// Now loop through the array of individual items
// Any containing the same child id are added to
// the second dropdown box
for ( x = 0 ; x < ItemArray.length ; x++ )
{
if ( GroupArray[x] == control.value )
{
myEle = document.createElement("option") ;
myEle.value = x ;
myEle.text = ItemArray[x] ;
controlToPopulate.add(myEle) ;
}
}
}
// End -->
Any help is appreciated
Cheers
Luigi
I have the following functions which take values from one dropdown and display values in the dependent dropdown based on the first dropdown. This works well except the number is being passed to the form on submit instead of the name thus.
"Form Confirmation
Manager_Delegate: 1
Completed_By: 1"
The code for the two dropdowns in the body is:
<SELECT id=Manager_Delegate name=Manager_Delegate onchange="selectChange(this, employmentForm.secondChoice, arrItems1, arrItemsGrp1);">
<option value=0 SELECTED>
<option value=1>Manager</option>
<option value=2>Delegate</option>
</select>
<select id=secondChoice name="Completed_By">
</select></td>
The functions are:
<!-- Begin
var arrItems1 = new Array();
var arrItemsGrp1 = new Array();
arrItems1[1] = "Jo Bloggs";
arrItemsGrp1[1] = 1;
arrItems1[2] = "Henry Paul";
arrItemsGrp1[2] = 1;
arrItems1[3] = "Henry Ford";
arrItemsGrp1[3] = 2;
arrItems1[4] = "Jeff Blink";
arrItemsGrp1[4] = 2;
function selectChange(control, controlToPopulate, ItemArray, GroupArray)
{
var myEle ;
var x ;
// Empty the second drop down box of any choices
for (var q=controlToPopulate.options.length;q>=0;q--) controlToPopulate.options[q]=null;
if (control.name == "Manager_Delegate") {
}
// ADD Default Choice - in case there are no values
myEle = document.createElement("option") ;
myEle.value = 0 ;
//myEle.text = "[SELECT]" ;
controlToPopulate.add(myEle) ;
// Now loop through the array of individual items
// Any containing the same child id are added to
// the second dropdown box
for ( x = 0 ; x < ItemArray.length ; x++ )
{
if ( GroupArray[x] == control.value )
{
myEle = document.createElement("option") ;
myEle.value = x ;
myEle.text = ItemArray[x] ;
controlToPopulate.add(myEle) ;
}
}
}
// End -->
Any help is appreciated
Cheers
Luigi