Loop through the elements of the form and add the value of any field whose
name begins with "Reg_". You may also want to put in some validation that
all the fields are numeric and do not contain any non-numeric characters.
function sumValues() {
var TheSum = 0;
for( var i=0; i<document.FormName.elements.length; i++) {
if( document.FormName.elements[i].name.search(/^Reg_/) != -1
) {
// put numeric validation here?
TheSum += document.FormName.elements[i].value;
}
}
}
HTH,
Nate
> -----Original Message-----
> From: Angel Stewart [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, November 13, 2001 9:40 AM
> To: CF-Talk
> Subject: Jscript totalling with dynamic CF Fields..
>
>
> Hello all,
>
> Umm..I'm in a bit of a bind.
> I have several rows of fields that are dynamically named like
> Reg_#CurrentDate# or VAC_#CurrentDate#.
>
> At the end of each row, I need a Total of the numbers entered into the
> fields to show dynamically, as the user enters values into
> each field.
>
> How in the nine hells am I going to do that? I will have to
> somehow pass
> the name of the field (which is dynamically generated) to some
> Javascript (or Vbscript it doesn't matter right now), and then do the
> calculation with the code attached to the onBlur() event of
> each field.
>
> But I have no idea where to even start with writing code like this.
>
> -Gel
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists