var firstValue = this.getField("valueOne").value;
I did the same on the second text field with -
var secondValue = this.getField("valueTwo").value;
Then for the third text field, which will show the sum, I'm not sure how to autofill it? I've tried something like -
event.value = (this.getField("valueOne + valueTwo").value=="") ? "";
It's not working - and I'm not sure how to have it just show up without using a trigger event?
Any advice would be much appreciated, thank you!
Do you want the sum field to be empty if one (or both) of the other fields is empty?
Yes. I'm also trying to get it to work on mobile devices. I found out a way to set it up by going to the calculate tab and having the sum field be the sum of the two other fields, and that works well, however when I test it on an iPhone 6 the sum is not appearing even after I enter two values into the other fields.
There are no guarantees it will work on a mobile device. If the built-in Sum command didn't work, it's not likely that a script will, either.
For best results on an iPad I recommend using PDF Expert by Readdle, although it's not free.
The code to use is:
var firstValue = this.getField("valueOne").valueAsString;
var secondValue = this.getField("valueTwo").valueAsString;
if (firstValue=="" || secondValue=="") event.value = "";
else event.value = Number(firstValue) + Number(secondValue);