Copy link to clipboard
Copied
I'm trying to write a script that will calculate the sum of two field if there is a value entered into one or both of the fields. So far, the custom calculation in the third field looks like this:
var c2 = this.getField(“Cargo WeightRow2”).value;
var t2 = this.getField(“Tare WeightRow2”).value;
if(c2 == “ ”) && (t2 == “ ”)
event.value = c2 + t2;
else if(c2 == “ ”) || (t2 == “ ”)
event.value = c2 + t2;
else if(c2 = “ ”) && (t2 = “ ”)
However, I want the user to be able to manually enter a value into the third field if both of the other fields are empty. Please help.
Copy link to clipboard
Copied
Have you tried your code in a form?
Do you get any errors displaying as you save the code or test the form?
You need to use a plain text editor and not a word processor with smart quotation marks.
MDN has the JavaScript Reference online for free and Adobe does the same for the Acrobat JavaScript Reference.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now