You are right that you can follow the same fashion to do all the fields.
I noticed that you have a typo that there is no left quote for GetValue(d3").
From: "Ronald C. Duke" <ronal...@inbox.com>
Sent: Tuesday, September 09, 2008 3:47 PM
To: cenos...@googlegroups.com
Subject: Re: Simple addition of Currency in a table
Would I use this same format for additional rows? I've added one more line
to your format so that you can see what I mean. The reason I want to know is
I have a total of 12 rows to total.
Function CalculateTotals()
{
This.getField("d1").value = GetValue("b1") + GetValue("c1");
This.getField("d2").value = GetValue("b2") + GetValue("c2");
This.getField("d3").value = GetValue("b3") + GetValue("c3");
This.getField("total").value = GetValue("d1") + GetValue("d2") + GetValue(
d3");
}
Function GetValue(fieldName)
{
Var s = this.getField(fieldName).valueAsString;
If(s == null || s.length == 0)
Return 0.0;
Return parseFloat(s);
}
-------Original Message-------
From: CenoPDF Support
Date: 9/8/2008 8:25:23 PM
To: CenoPDF Support Group
Subject: Re: Simple addition of Currency in a table
Hi Ronald,
Here is the sample I created for you. Please download it at:
http://groups.google.com/group/cenosupport/web/B2.doc Basically here are the steps to archieve what you want:
1. Change the name of the fields to b1, b2, c1 and c2
2. Added new fields d1, d2 and total.
3. Go to CenoPDF > Document Settings > Document Level JavaScript and
Click Add button, then type in the following script:
Function CalculateTotals()
{
This.getField("d1").value = GetValue("b1") + GetValue("c1");
This.getField("d2").value = GetValue("b2") + GetValue("c2");
This.getField("total").value = GetValue("d1") + GetValue("d2");
}
Function GetValue(fieldName)
{
Var s = this.getField(fieldName).valueAsString;
If(s == null || s.length == 0)
Return 0.0;
Return parseFloat(s);
}
4. Go to b1, b2, c1 and c2's properties window > Actions tab > On blur
> Add button > Action Type: JavaScript. Paste the following script:
CalculateTotals();
Basically this means any time if any of above boxes lose focus (user
Types in it, then click outside of it), it will call the function
CalculateTotals to calculate everything.
Thanks,
-- CenoPDF Support