antonyx6666
Programmer
hello, i am just having a bit of trouble.
i have a function and there are two problems, here is the function:
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:
I need this option to send both values to my database (in this format it has worked).
I'm quite sure the problem is in this line:
Is there a way I can edit the above to make sure both values are used when the option is selected?
Thanks
i have a function and there are two problems, here is the function:
Code:
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:
Code:
["Option Name", [ "Value1", "Value2" ]]
I need this option to send both values to my database (in this format it has worked).
I'm quite sure the problem is in this line:
Code:
optn.text = AS_Airport.dd2options[i][0];
optn.value = i;
Is there a way I can edit the above to make sure both values are used when the option is selected?
Thanks