Click to See Complete Forum and Search --> : Javascript: Changing a textbox value with an array as a name


The Letter J
June 3rd, 2005, 05:59 PM
I have a textbox with the following name: list_data[2][cost]

How would I change the value of that text box? I have tried the following and it doesn't work:

document.list.list_data[2][cost].value = '3.50';

It must be something stupid that I'm missing.

Dr. Script
June 3rd, 2005, 06:02 PM
Use it as an array:document.list.elements['list_data[2][cost]'].value = '3.50';If you want to loop thru:document.list.elements['list_data['+i+'][cost]'].value = '3.50';Dr. Script