Planet PDF Forum Planet PDF Forum
  New Posts New Posts RSS Feed - Recalc fields on Unfocus; From Document Level!
  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.

Recalc fields on Unfocus; From Document Level!

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

Joined: 05 Jun 2016
Points: 4
Post Options Post Options   Quote BlackPearl Quote  Post ReplyReply Direct Link To This Post Topic: Recalc fields on Unfocus; From Document Level!
    Posted: 05 Jun 2016 at 9:48pm
I've been a website developer since the 90s and a graphic designer since the 00s, this is my first foray into Scripting and PDFs...  My first form has 1800+ fields!

So my plan was to first layout the form then to do the script. (InDesign -> Acrobat)

I'm mostly done with the design and I've started venturing into the code.  A lot of things have been easy, adding up fields, duplicating values. conditional logic etc etc.  I'm trying to do as much as possible with a document level javascript because I'm sure that future versions will be made and the replace page feature doesn't seem to carry over form field properties, I'd rather just cut and paste one file of code.

Through testing I can get code to run on a field and store a value using event.value
but I don't want to have to enter a snippet of code for all 1800 fields...  And whenever I edit the document level script and submit it re-runs the code.  But can't get it to do anything inbetween.

I would like the code to rerun whenever I unfocus from a form field, ie finish editing one text box and when I click out and into another it recalculates.

Back to Top
Sponsored Links


Back to Top
gkaiseril View Drop Down
Senior Member
Senior Member


Joined: 15 Jul 2011
Location: USA
Points: 4071
Post Options Post Options   Quote gkaiseril Quote  Post ReplyReply Direct Link To This Post Posted: 05 Jun 2016 at 10:01pm
I would write all the scripts in a document level function. I would then select the last field that I want calculated and place the function call in the custom calculation fields.

If you place the call in the on blurr action, then the code will only execute when you leave that field. So if you change anyother field and do not cycle through the field with the on blur action your code will not execute and ypur changed field will not update your calculations.
Back to Top
BlackPearl View Drop Down
New Member
New Member
Avatar

Joined: 05 Jun 2016
Points: 4
Post Options Post Options   Quote BlackPearl Quote  Post ReplyReply Direct Link To This Post Posted: 06 Jun 2016 at 12:28pm
Can a function call be made from any of a group of fields, say a dozen or so?

How can I add a call to that function via a Document Level Script?  Something like:


for (i = 0; i < fields.length; i++) {
    this.getField( "FieldName" + i ).onBlur().do_the_math();
    // OR
    this.getField(( "FieldName" + i ).addEventListener("blur","do_the_math");
}


Something like one of these?
Back to Top
try67 View Drop Down
Senior Member
Senior Member


Joined: 15 Jul 2011
Points: 615
Post Options Post Options   Quote try67 Quote  Post ReplyReply Direct Link To This Post Posted: 08 Jun 2016 at 10:31am
Have a look at the setAction method of the Field object.
- Acrobat Expert - Contact me personally at try6767@gmail.com
Check out my custom-made scripts website: http://try67.blogspot.com
Back to Top
BlackPearl View Drop Down
New Member
New Member
Avatar

Joined: 05 Jun 2016
Points: 4
Post Options Post Options   Quote BlackPearl Quote  Post ReplyReply Direct Link To This Post Posted: 11 Jun 2016 at 1:47am
Originally posted by try67 try67 wrote:

Have a look at the setAction method of the Field object.


Worked a treat!

I was worried I wouldn't get a solution, so I most appreciate it.

Thank you very much.
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.