Copy link to clipboard
Copied
I need to perform a calculation in a textfield with booth addition and subtraction. Add two previous textfields and subtract another textfield.What does that looks like in javascript?
Copy link to clipboard
Copied
You can use the simplified field notation:
fieldA + fieldB - fieldC
Copy link to clipboard
Copied
Thank you but it doesnt work for me. Is it field name or functionname I shall use?
Copy link to clipboard
Copied
You must use the names of your fields.
Copy link to clipboard
Copied
Ok, but it wont work anyway!!! Is there something else I can do instead?
Copy link to clipboard
Copied
What happens when you use it? Did you check the calculation order?
Copy link to clipboard
Copied
Nothing happens, thats my problem. Yes the calculation order is ok.
Copy link to clipboard
Copied
Can you share the form?
Copy link to clipboard
Copied
How do I do that?
Copy link to clipboard
Copied
Here are instructions about how to share documents using Adobe's Document Cloud: Share Documents via Adobe's Document Cloud - KHKonsulting LLC
In general, the "simple field notation" only works if you don't have any spaces or other special characters in your field names. If you do, you need to escape those characters. In such a case, it may be easier to just switch to a JavaScript based calculation. In your case, the script would look like this:
event.value = Number(this.getField("fieldA").value) + Number(this.getField("fieldB").value) - Number(this.getField("fieldC").value);
Copy link to clipboard
Copied
Thank you! Now its working as it should, I changed the fieldnames.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now