i have a function and there are two problems, here is the function:
function Repopulate_DD2(){
var dd2=document.getElementById('DDvehAttr');
dd2.options.length=0;
//run a loop to populate drop down
for(var i=0; i<=AS_Airport.dd2options.length-1;i++){
var optn = document.createElement("OPTION");
optn.text = AS_Airport.dd2options[i][0];
optn.value = i;
dd2.options.add(optn);
}
}
Problem 1
When this repopulates my drop down menu, it sets the first option to have a value of 0. What I need is for the first option to have a value of -1, not 0.
I have tried setting dd2.options.length=-1; - this works but produces an error on the browser as ‘Invalid Argument’
Problem 2
When my drop down menu repopulates it creates an option using the following format:
["Option Name", [ "Value1", "Value2" ]]
I need this option to send both values to my database (in this format it has worked).
i have a value called vehAttribIndex and a session called VAindex.
i need to make sure that any new drop down values i create in my function are set to vehAttribIndex and the VAindex session is updated… i think?
function Repopulate_DD2(){
var dd2=document.getElementById('DDvehAttr');
dd2.options.length=0;
//run a loop to populate drop down
for(var i=0; i<=AS_Airport.dd2options.length-1;i++){
var optn = document.createElement("OPTION");
optn.text = AS_Airport.dd2options[i][0];
optn.value = i-1;
dd2.options.add(optn);
}
}