Planet PDF Forum Planet PDF Forum
  New Posts New Posts RSS Feed - Form Field Calculation and Input question
  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.

Form Field Calculation and Input question

 Post Reply Post Reply
Author
mmctighe View Drop Down
New Member
New Member
Avatar

Joined: 18 Apr 2016
Points: 2
Post Options Post Options   Quote mmctighe Quote  Post ReplyReply Direct Link To This Post Topic: Form Field Calculation and Input question
    Posted: 18 Apr 2016 at 8:15pm
Looking for some help with a form field calculation.   
Is it possible to have a field that calculates if no input?

I have a contract form that has 4 fields. Currently it takes the inputed total and divides into 3 equal payments.   My sales group is wanting to have the option of inputting in the first payment (Pay1) amount.  

total = amount is put in, no calculation

Pay1 = if (this.getField("total").valueAsString=="") event.value = "";
else event.value = ( this.getField("total").value / 3 );  

Pay2 = if (this.getField("total").valueAsString=="") event.value = "";
else event.value = ( this.getField("total").value / 3 );  

Pay3 =  if (this.getField("total").valueAsString=="") event.value = "";
else event.value = ( this.getField("total").value / 3 );    

What I would like is if Pay1 is manually entered, then do not perform the script. 
(What follows is not a script, just generalized for demonstrating what will happen if I can get the above correct.  )
I would then re-write the Pay2 to =(total-pay1)/2
Pay3=total-pay1-pay2.  

Thanks for taking the time to review and respond.    
Thank you,
Michele
Back to Top
Sponsored Links


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: 20 Apr 2016 at 8:55pm
Here is a link that describe a solution:


As the answerer in the link points out, a tricky issue with this approach is: what if the user changes their mind and wants to let the form do the calculation after all? Without some care, the calculation formula may be 'wiped out' altogether, and they won't be able to let the form do the calculation. For this reason, it makes sense to have on 'override' checkbox on the form that will switch between calculating all three payments, or manually entering the first payment.
Rob Lyman
Software Engineer
http://www.datalogics.com
Back to Top
mmctighe View Drop Down
New Member
New Member
Avatar

Joined: 18 Apr 2016
Points: 2
Post Options Post Options   Quote mmctighe Quote  Post ReplyReply Direct Link To This Post Posted: 21 Apr 2016 at 10:42pm
Thanks for the help.  I ultimately ended up going in a little bit different direction, but this article helped with the inspiration.   I used a button instead of checkbox.   


Total - manually entered field
I then had a Read-only field that divided by 3, directly below that I put a button to paste this amount to pay1 field, if they so desire.
pay1 -can manually enter or leave as is from the pasted button
pay2 -subtracts pay1 from total and truncates the decimals
pay3 -subtracts pay1 and pay2 from total
Thank you,
Michele
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.029 seconds.