Sorry, my Javascript is a bit rusty. This is all ASP-driven so I may have to go into more detail later, but for now:
I've got an array containing names of select boxes:
I populate these select boxes from a database:
the "25" in this example is the database ID field.
When a user chooses, say, a first name, I want any other select boxes on the page that are populated from the same database data to change to reflect that. If I select "Bill" in the FirstName, I want the Surname to change to "Gates". It shouldn't be too hard because their index values are both gonna be 25.
Here's the function I call onChange:
which - should - loop through all the relevant select box names and make their selectedIndex whatever was sent to it in "whichIndex". Right?
All it does is sets all the relevant select boxes - those in my array - to blank, and I'm not sure why. Any suggestions?
Cheers.
I've got an array containing names of select boxes:
Code:
employeeFields[0]="FirstName"; employeeFields[1]="Surname";
Code:
<select name="FirstName" onChange="updateEmployeeFields(this.options[this.selectedIndex].value)"> <option value="25">Bill</option> </select> <select name="Surname" onChange="updateEmployeeFields(this.options[this.selectedIndex].value)"> <option value="25">Gates</option> </select>
When a user chooses, say, a first name, I want any other select boxes on the page that are populated from the same database data to change to reflect that. If I select "Bill" in the FirstName, I want the Surname to change to "Gates". It shouldn't be too hard because their index values are both gonna be 25.
Here's the function I call onChange:
Code:
function updateEmployeeFields(whichIndex){ for(i=0;i<employeeFields.length;i++){ eval("document.form1."+employeeFields[i]+".selectedIndex="+whichIndex); } }
All it does is sets all the relevant select boxes - those in my array - to blank, and I'm not sure why. Any suggestions?
Cheers.
Comment