Click to See Complete Forum and Search --> : Evaluating variable in literal?


derekmceachern
11-04-2003, 10:50 AM
I have a web page where the user selects an item from a select box and when they make that selection I want to change the information on the web page.

The variable i is the index of the selected item in form "maturity". In another form called "hidden_data" on the same page there is a hidden variable called description_1. What I want to do is set a text box to the value of description_1 but reference it with i.

Current Code:

function maturityChange () {
var i = 0;
i=document.maturity.maturity_item.options[document.maturity.maturity_item.selectedIndex].value;
document.maturity.description.value=document.hidden_data.description_i.value;
}

What I need is in the above code to have i evaluated to 1, how do I do this?

pyro
11-04-2003, 10:53 AM
I'm not really sure what you are asking, so as a stab in the dark, try:

function maturityChange () {
var i = 0;
i = document.maturity.maturity_item.options[document.maturity.maturity_item.selectedIndex].value;
document.maturity.description.value = document.hidden_data.elements["description_"+i].value;
}

derekmceachern
11-04-2003, 10:59 AM
This is exactly what I want.

Thank you.

pyro
11-04-2003, 11:42 AM
You bet... :D