Counter value in drop down

hello, i am just having a bit of trouble.

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’m quite sure the problem is in this line:

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

ignore this, i will try to fix it and see what i come up with. thanks

ok, can someone tell me how to do the following:

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);

}

}

in the function above how can i do this?

hi, that has worked, it has fixed the counter like i wanted. thank you very much.

with regards to problem 2 i think i know how to fix it. basically i need to set the values of the new options as vehAttribIndex (i think)

how would i set those values to be the above in my function?

try

 
optn.value = i-1;

I have a function that changes some values in a drop down menu. This is the function:


function Repopulate_DD2(){
var dd2=document.getElementById('DDvehAttr');
dd2.options.length=0;
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);

}

}

what i want to do is make sure that the new values b[/b] are added to a session. this sessions is called VehAttr

how can i achieve this?

is there anyway i can do something like the following:


function Repopulate_DD2(){
var dd2=document.getElementById('DDvehAttr');
dd2.options.length=0;
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);

[b]AS_Airport.dd2options = <&#37; Session("VehAttr")
REFRESH Session("VehAttr") %>[/b]

}

}

i’m sure it is very simple but i just dont know the correct syntax. thanks