Javascript variable in element name -


i have text box, , select box choices same columns in table. want able type in box, select column, press button, , have copy whatever in box, every box in column. having hard time syntax using variable thing prevents working. when put in real values, works fine.

function testscript(fill) { choice=document.form1.column.value; alert (fill); alert (choice);     for($i=0;$i<fill;$i++){         document.form1.choice[$i].value=document.form1.copy.value;     } } 

fill (tested alert) provides me number of rows in table , works fine. choice select (drop down) box. if type in "document.form1.make[$1].value= fills type in every row of make column. if choose make in select box, choice make indicated test alert.

any ideas how use variable correctly in loop?

function testscript(fill) {     choice=document.form1.column.value+'[]';     for($i=0;$i<fill;$i++){         document.form1.elements[choice][$i].value=document.form1.copy.value;     } } 

updated

view sample here: jsfiddle link


Comments

Popular posts from this blog

jasper reports - Fixed header in Excel using JasperReports -

media player - Android: mediaplayer went away with unhandled events -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -