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

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

Community Beginner ,
Jun 18, 2021 Jun 18, 2021

Copy link to clipboard

Copied

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

Views

5.2K

Translate

Translate

Report

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

correct answers 4 Correct answers

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.

Votes

Translate

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

Votes

Translate

Translate
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;

Votes

Translate

Translate
Community Expert , Jun 21, 2021 Jun 21, 2021

Make sure field name is Deposit.

Votes

Translate

Translate
Community Expert ,
Jun 18, 2021 Jun 18, 2021

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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 

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

I have tried it. Somehow it dont works 

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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?

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

yes by default it should show zero.

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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;

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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, 

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

Seems fine. Can you share the actual file?

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

Make sure field name is Deposit.

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied


Thank you for asking me to check field name,

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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, 

Votes

Translate

Translate

Report

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