Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Calculating javascript in a textfield

New Here ,
May 03, 2017 May 03, 2017

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?

TOPICS
Acrobat SDK and JavaScript , Windows
776
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 03, 2017 May 03, 2017

You can use the simplified field notation:

fieldA + fieldB - fieldC

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 03, 2017 May 03, 2017

Thank you but it doesnt work for me. Is it field name or functionname I shall use?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 03, 2017 May 03, 2017

You must use the names of your fields.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 03, 2017 May 03, 2017

Ok, but it wont work anyway!!! Is there something else I can do instead?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 03, 2017 May 03, 2017

What happens when you use it? Did you check the calculation order?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 03, 2017 May 03, 2017

Nothing happens, thats my problem. Yes the calculation order is ok.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 03, 2017 May 03, 2017

Can you share the form?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 03, 2017 May 03, 2017

How do I do that?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 03, 2017 May 03, 2017

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);
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 03, 2017 May 03, 2017
LATEST

Thank you! Now its working as it should, I changed the fieldnames.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines