[thelist] dynamic javascript loop help

Chris Heilmann lists at onlinetools.org
Mon Jan 17 10:46:32 CST 2005


>
> function initvalues() {
>
> 	var theform = document.getElementById("frmdefault");
>
> 	for(var a=0; theform.ycounter.value -1; a++)
> 	{
> 		for(var f=0; theform.fcount.value; f++)
> 		{
> 			theform.datarow_+a+_col_+f+.value = row_+a+_col_+f+.innerHTML;
> 		}
> 	}
>
> }

You need to use eval.

var tmpfield=eval('theform.datarow_'+a+'_'+f)
var tmpsource=eval('row_'+a+'_'+f)
tmpfield.value=tmpsource.innerHTML

should do it.


-- 
Chris Heilmann
http://icant.co.uk/ | http://www.onlinetools.org/



More information about the thelist mailing list