Skip to main content
January 15, 2019
質問

I have entered a formula into a text box to pull calculations from other text boxes, now i want to be able to also manually enter numbers into that text box with a formula. Can i do this?

  • January 15, 2019
  • 返信数 1.
  • 746 ビュー

I have created a formula in adobe pro fillable forms the formula works fine, but i need to be able to manually enter numbers into it as well.

Is this something that i can do?

このトピックへの返信は締め切られました。

返信数 1

Thom Parker
Community Expert
Community Expert
January 15, 2019

Please explain more, and be clear. Provide a screen shot

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
January 15, 2019

I have a formula in the text box under total, it calculates anything that is put into the #of Km's as well as breakfast/Lunch/Dinner Columns. I want the option to be able to manually enter say 25.00 into the total text box but still keeping the formula.

Thom Parker
Community Expert
Community Expert
January 15, 2019

You want to override the calculation. This can be done, but it's tricky. 

First, your calculation has to be a custom script that uses "event.value" to set the Total field value, and does not have any standard formatting.

Next. the "event.rc" property enables or overrides setting the calculation value. So the issue is, "how do you set and clear this value?"

The answer is to use the keystroke event to set an override indicator.

Add this code to the keystroke event.

if(event.willCommit) event.target.setOverride = (event.value !="");

And add this code to the top of your calculation script

event.rc = !event.target.setOverride

Entering any value into the total field will overrride the calculation,

Clearing the value from the total field will reset the override and allow the calculation to continue.

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often