How to calculate fields in an Acrobatdc form using javascript?

Asked

Viewed 370 times

1

I have a PDF form and I want one of the items to work as follows: After the fields A, B, C, and D are filled in, at another point of the form, A, B, C and D appear as options for a listbox. According to the chosen option, the original field (A, B, C or D) is added to Field Y, and the result appears in field X. How to link the choice of the field to be added to the choice in the listbox? Detail: I don’t understand any javascript, just enough to copy the code from one place and paste in the other, replacing the field names.

I’m using Adobe Acrobat DC, which allows me to create forms with an intuitive interface, but which uses scripts for calculations. It allows me to take two fields and calculate inside this interface, but I don’t know how to deal with the listbox.

I think I know how to explain better what I need: I want to know how to work the listbox to import the value of the other field so I can add the listbox object (if that’s possible) to another object. Example: My listbox has options A, B and C. Let’s assume that A equals 5, B equals 4 and C equals 7. These values will be entered by the end user. What I want is a way to make the value of the selected object, A, B or C, temporarily become the value of my listbox so I can add listbox + Y.

  • Javascript inside the PDF or in an HTML page that calls the PDF? It’s a little hard to understand what you’ve done, it’s actually quite hard to understand almost everything.

  • @Guilherme-birth, would be within the PDF. The fields already exist, what I do not know how to do is to link the fields A, B, C and D to the items of the same name of listbox. Clearer?

  • I know little Acrobatdc, I only moved once to create a PDF form, however it would be easier if you explain +or- like this form

  • I can post links here?

  • It depends on the link, but it doesn’t hurt to try

  • https://files.acrobat.com/a/preview/18198919-9670-46be-b29b-7fa9a311c8ac

  • Lais as the question is closed I will not get by a script a little more complete, but even if I could I think it would not help you, so I will try to give you a way, to get the wanted listbox use var f = this.getField("ListBox1"); (change Listbox1 by the name of the desired listbox) and then with var a = f.currentValueIndices; you will pick up only the selected items, and just add them up using a for

  • I’ll try to reopen the question

  • I’ll try here, thank you!

  • Laís I think I managed to make a complete example, in the morning I talk to a moderator to reopen the question and put the code and some explanations, until soon.

  • Thank you for your help, Guilherme! What you have already given me, the program is not accepting. It simply goes away.

Show 6 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.