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

How to get a button value in another text filed if specific button is clicked

Community Beginner ,
Jun 18, 2021 Jun 18, 2021

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.

TOPICS
PDF forms
7.9K
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
4 ACCEPTED SOLUTIONS
Community Expert ,
Jun 18, 2021 Jun 18, 2021

In each  Button actions tab as 'Mouse UP' event,select 'Run javascript' and add this code:

this.getField("Deposit").value = 5;

Of course change 5 to each button value.

View solution in original post

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 ,
Jun 19, 2021 Jun 19, 2021

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("%", "");

View solution in original post

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 ,
Jun 19, 2021 Jun 19, 2021

Go to Tools - JavaScript - Document Javascripts and create a new item. Call it "load", for example.

Delete all the default code that's generated and replace it with the following:

this.getField("Deposit").value = 0;

View solution in original post

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 ,
Jun 21, 2021 Jun 21, 2021

Make sure field name is Deposit.

View solution in original post

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 ,
Jun 18, 2021 Jun 18, 2021

In each  Button actions tab as 'Mouse UP' event,select 'Run javascript' and add this code:

this.getField("Deposit").value = 5;

Of course change 5 to each button 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
Community Beginner ,
Jun 19, 2021 Jun 19, 2021

Thank you Nesa for your line of code also worked great. Thank you very much for your quick response.

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 Beginner ,
May 11, 2022 May 11, 2022

Hi there,

How can i change a dropdown list item with a click of a button. Your method works for a text box. But not working for a dropdown list.

 

Pls help

 

Thanks 

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 11, 2022 May 11, 2022

It should work just the same. Of course, the value you select must be one of the options in the field's list.

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 Beginner ,
May 11, 2022 May 11, 2022

I have tried it. Somehow it dont works 

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 11, 2022 May 11, 2022
LATEST

You need to be more specific if you want help with this issue. Are there any error messages in the Console? What exactly happens when you use it? Can you share the code, or the actual file with us?

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 ,
Jun 19, 2021 Jun 19, 2021

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("%", "");

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 Beginner ,
Jun 19, 2021 Jun 19, 2021

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.

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 Beginner ,
Jun 19, 2021 Jun 19, 2021

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.

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 ,
Jun 19, 2021 Jun 19, 2021

What do you mean by "by default", exactly? When should it show zero? When the file is opened, and before any buttons are clicked?

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 Beginner ,
Jun 19, 2021 Jun 19, 2021

yes by default it should show zero.

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 Beginner ,
Jun 19, 2021 Jun 19, 2021

I mean before any buttons are clicked it should display "0" by default, thanks

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 ,
Jun 19, 2021 Jun 19, 2021

That would mean that the value you selected will not be saved when you close the file, though...

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 Beginner ,
Jun 19, 2021 Jun 19, 2021

Yes exactly, when I close the document the value should not be saved.

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 ,
Jun 19, 2021 Jun 19, 2021

Go to Tools - JavaScript - Document Javascripts and create a new item. Call it "load", for example.

Delete all the default code that's generated and replace it with the following:

this.getField("Deposit").value = 0;

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 Beginner ,
Jun 19, 2021 Jun 19, 2021

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, 

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 ,
Jun 20, 2021 Jun 20, 2021

Can you post a screenshot of where you placed the code, or share the file with us?

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 Beginner ,
Jun 20, 2021 Jun 20, 2021

Sure, I am attaching the screenshot where I put the code and you can see by default 5 is displayed by default. thanks

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 ,
Jun 20, 2021 Jun 20, 2021

Seems fine. Can you share the actual file?

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 ,
Jun 21, 2021 Jun 21, 2021

Make sure field name is Deposit.

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 Beginner ,
Jun 21, 2021 Jun 21, 2021


Thank you for asking me to check field name,

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 Beginner ,
Jun 21, 2021 Jun 21, 2021

Hi, it worked, actually the field id i was entering incorrect.  After adding correct field ID it worked.  Thanks once again you saved my day, 

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