Planet PDF Forum Planet PDF Forum
  New Posts New Posts RSS Feed - Need an In-Field Calculator Function
  FAQ FAQ  Forum Search   Register Register  Login Login


Hi, welcome to the Foxit Planet PDF Forum. If you have PDF or Adobe Acrobat questions then the right place to ask them is here, in this forum.

Need an In-Field Calculator Function

 Post Reply Post Reply
Author
Beachbum View Drop Down
New Member
New Member


Joined: 11 Mar 2015
Location: NJ
Points: 2
Post Options Post Options   Quote Beachbum Quote  Post ReplyReply Direct Link To This Post Topic: Need an In-Field Calculator Function
    Posted: 21 Sep 2015 at 3:04pm
I created a new expense form with a bunch of numeric fields for things such as transportation, lodging, meals, etc.  This form replaced an Excel spreadsheet.  Everything works fine, but now users miss the Excel sum (=) function to manually calculate a total for a field themselves.

 

For example, a user has four different charges for transportation that he needs to total up, and then needs to enter that total in the transportation numeric field of the form.  In the Excel version, the users had the ability to do an on-the-fly calculation, or sum, right in a cell, instead of using a calculator.  The user would click on the transportation cell, type the "=" sign, followed by the values to add, and press Enter.  Example:  =20+10+15+25   (and Press Enter)    This would enter the value of 70 in the Transportation cell.  It makes it simpler and quicker than having to open Calc, enter the numbers, and transfer the total.


Here's a quick video demonstrating the method in Excel:  https://www.dropbox.com/s/05d0umq89ky46do/Sum%20in%20a%20Field.mp4?dl=0

 

It would be really helpful if there was some sort of JavaScript to allow the same functionality in LiveCycle forms.  Has anyone attempted to accomplish this before to allow for in-field calculations by the user?  If this is possible, how would I go about doing it?

 

Thanks!

Back to Top
Sponsored Links


Back to Top
gkaiseril View Drop Down
Senior Member
Senior Member


Joined: 15 Jul 2011
Location: USA
Points: 4076
Post Options Post Options   Quote gkaiseril Quote  Post ReplyReply Direct Link To This Post Posted: 21 Sep 2015 at 10:06pm
If one had fields for those items and then have the total field sum them up. Many companies require the that daily expenses be totaled into special account codes so there will be a total for the day's expenses and a total for the week's expenses categorized into lodging, meals (needed for special IRS adjustment for meals), gas (for possible motor fuel taxes) laundry, tips, entertainment, and Misc.
It is even possible to enter a series of number separated by blanks or comas and sum them. With a lot of coding one can even create a calculator.
 
With the complex coding that is required for in field calculations you might not be able to get your form to work on mobile devices.
Back to Top
Beachbum View Drop Down
New Member
New Member


Joined: 11 Mar 2015
Location: NJ
Points: 2
Post Options Post Options   Quote Beachbum Quote  Post ReplyReply Direct Link To This Post Posted: 21 Sep 2015 at 10:28pm
Thanks for your reply.

Yes, I already have the fields summing up into Total fields.

I'm specifically asking about finding a similar solution to Excel's = (sum) function that can be done in a cell.  The video I posted shows what I am looking to do.  I know how to sum values from multiple fields.  That is not what I am attempting to do.  I am looking for a solution to sum during the data entry of a field.  

To further explain, the form has a list of expense categories down the left side of the table.  Then there are 7 fields across for each day of the week.  What I want to do is allow the user to put the cursor in a field, such as Monday for Transportation.  If the user has several transportation expenses for Monday, rather than having to open Calc or using a regular calculator, they would be able to click on the field and enter the individual values in an on-the-fly sum formula like you can do in Excel.  So if the user has multiple expenses that he has to total up and enter in Monday's Transportation field, he would be able to click on the field, type =, followed by the different expense amounts, separating each one with a + sign, and pressing Enter.  This would put the resulting total into Monday's Transportation field.

Here's a link to a picture of the form.



Edited by Beachbum - 21 Sep 2015 at 10:47pm
Back to Top
gkaiseril View Drop Down
Senior Member
Senior Member


Joined: 15 Jul 2011
Location: USA
Points: 4076
Post Options Post Options   Quote gkaiseril Quote  Post ReplyReply Direct Link To This Post Posted: 25 Sep 2015 at 8:28pm

Have you created many forms in Acrobat?

Pretty hard to enter text into a field formatted as a number so you would need to format the field as "None" and then provide your own validation formatting for the numeric results. Now you need to figure out how to sum the formatted numbers.
 
You could provide a scratch sheet to do the math and then cut and paste the result into the cell.
 
There are 4 function calculators that could be added to a PDF form.
Back to Top
Rob Lyman View Drop Down
New Member
New Member
Avatar

Joined: 12 May 2015
Location: Chicago
Points: 25
Post Options Post Options   Quote Rob Lyman Quote  Post ReplyReply Direct Link To This Post Posted: 07 Oct 2015 at 9:31pm
What you need is an equation parser written in Javascript. Here's an example of one: https://code.google.com/p/js-equation-parser/

You'd add this Javascript as a document level script so that it can be called throughout the PDF.

Then you just need to add a custom calculation script to the field like the following:

eq = owenge.equation.parse(event.value);
event.value = eq.answer;

Note that you'll still need to trim off the leading equal sign. As gkaiseril notes, the field should have a format of 'None'.


Rob Lyman
Software Engineer
http://www.datalogics.com
Back to Top
gkaiseril View Drop Down
Senior Member
Senior Member


Joined: 15 Jul 2011
Location: USA
Points: 4076
Post Options Post Options   Quote gkaiseril Quote  Post ReplyReply Direct Link To This Post Posted: 08 Oct 2015 at 4:21pm
One might try the "eval()" property to evaluate the input values.
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.10
Copyright ©2001-2017 Web Wiz Ltd.

This page was generated in 0.016 seconds.