[thelist] dynamic javascript loop help

Robert Vreeland vreeland at studioframework.com
Tue Jan 18 06:45:33 CST 2005


You need quotes around your strings. Try this
nDatarow = "datarow_" + a + "_col_" + f;
nValue = "row_" + a + "_col_" + f;
theform.nDatarow .value = document.getElementById(nValue).innerHTML;

Robert Vreeland
Managing Partner
StudioFramework
----- Original Message ----- 
From: "Brian Cummiskey" <Brian at hondaswap.com>
To: <thelist at lists.evolt.org>
Sent: Monday, January 17, 2005 10:58 AM
Subject: [thelist] dynamic javascript loop help


> I'm working on a disgusting form.  :p
> 
> it can be anywhere from 0-100 rows, and 0-27 fields depending on what is 
> selected on previous pages.  since i have to do some math on the data 
> AFTER the pull, i've decided to do it with JS on the client side 
> (controlled IE6 environment.)
> 
> 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)
> 
> ycounter and fcount are defined via the asp pull, put into hidden form 
> vars and are not the issue.
> 
> 
> 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;
> }
> }
> 
> }
> 
> 
> 
> the problem here, is that i can't seem to assign the dynmic form field 
> value with the counter vars, a and f.  Doesn't seem to like the + for 
> concatination.
> 
> anyone know what i'm doing wrong?
> 
> 
> 
> 
> example html row i need to fill in:
> 
> <td><input type="text" name="datarow_0_col_0" value="" /></td>
> 
> 
> example html row derrived from asp, and hidden (via css) (this is the 
> pre-math field that i need to get from the db, but need to calculate on 
> before displaying to the user):
> 
> <td id='row_0_col_0'>value here</td>
> 
> -- 
> 
> * * Please support the community that supports you.  * *
> http://evolt.org/help_support_evolt/
> 
> For unsubscribe and other options, including the Tip Harvester 
> and archives of thelist go to: http://lists.evolt.org 
> Workers of the Web, evolt !


More information about the thelist mailing list