[thelist] dynamic javascript loop help

Phil Turmel philip at turmel.org
Mon Jan 17 10:39:37 CST 2005


Brian Cummiskey wrote:
[snip]
> Basically, i need to set the value of my display form to the field (the 
> "datarow_" vars) of the pull form vars (the "row_" vars)

>             theform.datarow_+a+_col_+f+.value = row_+a+_col_+f+.innerHTML;

> <td><input type="text" name="datarow_0_col_0" value="" /></td>
[/snip]

javascript is treating "theform.datarow_" as an item to concatenate with 
a, then "_col_", then f then .value.  You need to concatenate the 
strings, then look up the element, like so:

var thefield = theform.elements.namedItem("datarow_"+a+"_col_"+f);
var thevar = theform.elements.namedItem("row_"+a+"_col_"+f);
thefield.value = thevar.innerHTML;

[***UNTESTED***]

HTH

Phil Turmel


More information about the thelist mailing list