Click to See Complete Forum and Search --> : child dropdown showing number not name


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

Khalid Ali
10-12-2003, 07:19 PM
when data is sent to the webserver,its sent in this format

elementName=value,

which means youwill need to make change in the list box so that value is manager or ...etc

LuigiX
10-12-2003, 09:00 PM
Hi Khalid

Could you clarify this a little.

I tried changing from:
<option value=1>Manager</option>

etc..

to..

<option value=Manager>Manager</option>

and the script to..

arrItems1[1] = "John Smith";
arrItemsGrp1[1] = Manager;

etc...

but the child dropdown is blank.

Any suggestions????

Cheers

Luigi