Copy link to clipboard
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?
Copy link to clipboard
Please explain more, and be clear. Provide a screen shot
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.
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.
so where would i enter in the formula that i need to calculate the other text boxes? Also where do i put they Keystroke Event?
sorry i am very new with the adobe so i don't know a lot about it.
the formula that i have right now is
Another option, beside what Thom described, is to add a condition to the calculation script to only update the value using the formula if the field that triggered the event (the "source" of it) is one of those fields that appear in the formula. That will allow you to manually override it, but that manual value will be overwritten if you change one of those fields.
To perform the action suggested by Try67, add this code as the first line of your calculation script:
event.rc = (event.targetName != event.source.name);
This doesn't really work because the field value is not maintained. You need a simple state machine to latch the value in. And then a specific reset condition.
It can work the way I described, and there's no need for this "state machine". Let's take a simple example where you have two fields called Text1 and Text2 and the value of Text2 should be twice that of Text1, but should also be possible to enter manually.
Using this code as the custom calculation script of Text2 will achieve that:
if (event.source && event.source.name=="Text1") event.value = Number(this.getField("Text1").valueAsString)*2;
The manually entered value will be kept, even if a third field is edited. It will only update automatically when Text1 is edited.
Of course, if the value is dependent on multiple fields then they all need to be added to the first part of the if-statement, but the principle is the same.
I have tried entering this and can not seem to get it to calculate - Can i send you my document so you can see better what i am trying todo?
Yes, but you should know I usually charge for private consultations. You can send it to [try6767 at gmail.com], if you wish.