Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Updating form totals using checkboxes

Status
Not open for further replies.

paoloc

IS-IT--Management
Aug 14, 2002
14
0
0
US
Hi there,
I'm trying to update a total in a form while selecting individual values using a checkbox.

I have the following js:

function recalc(doc)
{
var total=eval("doc.detail.hiddentotal.value");
var amount=eval('doc.elements["Bal" + doc.name].value');

if (doc.checked == false) {
doc.detail.hiddentotal.value=eval(total)-eval(amount);
}
else {
doc.detail.hiddentotal.value=eval(total)+eval(amount);
}
return (eval("doc.detail.hiddentotal.value") );
}


and the following form:

<form action=&quot;MailStatement.cfm?code=#url.code#&quot; method=&quot;post&quot; name=&quot;detail&quot; id=&quot;detail&quot;>
.... form stuff...

<cfoutput query=&quot;qDetail&quot;>
.... query stuff ....

<td align=&quot;right&quot;>#dollarformat(qDetail.balance)#</td>
<td align=&quot;center&quot;><input type=&quot;checkbox&quot; name=&quot;#cSelectKey#&quot; value=&quot;1&quot; onclick=&quot;this.form.nTotal.value=recalc(this);&quot; >

<input type=&quot;hidden&quot; value=&quot;#qdetail.balance#&quot; name=&quot;Bal#cSelectKey#&quot;></td>
...more stuff...
...end of loop...

<input type=&quot;text&quot; name=&quot;nTotal&quot; value=&quot;#nTotal#&quot;>
<input type=&quot;hidden&quot; name=&quot;hiddentotal&quot; value=&quot;#ntotal#&quot;>


...end of form....

The result returned is undefined.
Can anyone tell me what I'm doing wrong or point me to detail FAQ w/examples on how to do this?

Tks/Rgds
__PC

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top