Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

counter value in drop down

Status
Not open for further replies.

antonyx6666

Programmer
Sep 9, 2010
38
GB
hello, i am just having a bit of trouble.

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
 
i have fixed the counter value by using:

optn.value = i-1;
 
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?

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-1;
dd2.options.add(optn);

}

}

in the function above how can i do this?
 
I have a function that changes some values in a drop down menu. This is the function:

Code:
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 (AS_Airport.dd2options) 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:

Code:
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 = <% Session("VehAttr")
REFRESH Session("VehAttr") %>[/b]

}

}


i'm sure it is very simple but i just dont know the correct syntax. thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top