Simple addition of Currency in a table

6 views
Skip to first unread message

Ronald C. Duke

unread,
Sep 8, 2008, 9:38:28 PM9/8/08
to cenos...@googlegroups.com
                                                                                        
 
Please see attached file.  I want to know how I can format this so that columns B, C are added and the sum is posted in D.  Then the sum of all of column D is calculated at the bottom of column D.
 
Any help is very much appreciated.  I don't know Java script.

3D Marine Aquarium Screensaver Preview
Free 3D Marine Aquarium Screensaver
Watch dolphins, sharks & orcas on your desktop! Check it out at www.inbox.com/marineaquarium
rcdlogowithrevolvingarrowandlettercolorchangearrowchange.gif
graphics_icons_logos_animation.gif
header_divider.png
footer.jpg
B.doc
B.doc

CenoPDF Support

unread,
Sep 8, 2008, 11:25:24 PM9/8/08
to CenoPDF Support Group
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

Ronald C. Duke

unread,
Sep 9, 2008, 6:44:31 PM9/9/08
to cenos...@googlegroups.com
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
Reply all
Reply to author
Forward
0 new messages