We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.
Hi, Could someone help me in adding a script to my PDF form, I have 8 buttons namely (5%, 10%, 15%, 20%, 25%, 30%, 35%, 40%), if one click on one of the buttons the value of that button should be displayed in another field called "Deposit" dynamically. For example if I click on 10% button, the "Deposit" field should display 10 and if I click on 30%button it should display 30 in "Deposit" field. And I would like to use the said value for calculating the percent and add it to the sub-total and display in the "Total" field.
Thanks in advance.
this.getField("Deposit").value = 5;
Of course change 5 to each button value.
Thank you Nesa for your line of code also worked great. Thank you very much for your quick response.
Buttons don't have a value. I assume you mean the label.
In that case you can use something like this as the MouseUp event of all the buttons:
this.getField("Deposit").value = event.target.buttonGetCaption().replace("%", "");
Thank you very much, I can't thank you enough. I have spent hours figuring it out . Thanks to Adobe's community here I got the solution. Thank you once again.
Hi there, can I keep the Deposit field "0" zero by default? Since it is showing the last value I have entered, I am sorry if I am bothering you again, thanks in advance.
What do you mean by "by default", exactly? When should it show zero? When the file is opened, and before any buttons are clicked?
yes by default it should show zero.
I mean before any buttons are clicked it should display "0" by default, thanks
That would mean that the value you selected will not be saved when you close the file, though...
Yes exactly, when I close the document the value should not be saved.
Delete all the default code that's generated and replace it with the following:
this.getField("Deposit").value = 0;
HI, thanks for the piece of code, I have added the code as you instructed but the deposit value still remains and not going zero,
Can you post a screenshot of where you placed the code, or share the file with us?
Seems fine. Can you share the actual file?
Make sure field name is Deposit.
Thank you for asking me to check field name,