Text field or Export Value for Button

Community Beginner ,
Mar 24, 2021 Mar 24, 2021

Copy link to clipboard

Copied

I know that we can add text for the Export Value for a checkbox but is it possible to do the same for a regular Button?  If so, does this involve using Javascript under the Action tab in the Button Properties?

TOPICS
How to, JavaScript, PDF forms

Views

361

Likes

translate

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 1 Correct Answer

Adobe Community Professional , Mar 25, 2021 Mar 25, 2021
Try this code:if(this.getField("Text1").value != "")this.getField("Text1").value = "";else this.getField("Text1").value = "123";

Likes

translate

Translate

Translate
Adobe Community Professional ,
Mar 24, 2021 Mar 24, 2021

Copy link to clipboard

Copied

Is not possible for a button but you may add a readonly hidden textfield with a value and declare that field's value as variable that can be used in your Mouse event script.

 

Alternatively, I think that you can also decalre a global variable via document level script and call it from the event script in that button.

 

I am not 100% sure if this latter method will work though.

Likes

translate

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 ,
Mar 25, 2021 Mar 25, 2021

Copy link to clipboard

Copied

Thank you for your advice.  Could you please give me an example of what script would need to be used to perform this?

Likes

translate

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
Engaged ,
Mar 25, 2021 Mar 25, 2021

Copy link to clipboard

Copied

You need to tell us what exactly you trying to achive?

Likes

translate

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
Most Valuable Participant ,
Mar 25, 2021 Mar 25, 2021

Copy link to clipboard

Copied

Buttons don't have a value, nor an export value. You can fake one, of course, by populating a (hidden) text field with a value when the button is clicked. What exactly are you trying to achieve by assigning a value to a button, and how should it work?

Likes

translate

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 ,
Mar 25, 2021 Mar 25, 2021

Copy link to clipboard

Copied

That would work.  How to I populate a hidden text field with a value when a button is clicked?

Likes

translate

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
Most Valuable Participant ,
Mar 25, 2021 Mar 25, 2021

Copy link to clipboard

Copied

As the MouseUp event of the button enter this code:

this.getField("Text1").value = "123";

Likes

translate

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 ,
Mar 25, 2021 Mar 25, 2021

Copy link to clipboard

Copied

That works.  Thank you.  Is it possible to unselect the button so that the "123" is removed from the Text1 field?

Likes

translate

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
Adobe Community Professional ,
Mar 25, 2021 Mar 25, 2021

Copy link to clipboard

Copied

Try this code:

if(this.getField("Text1").value != "")
this.getField("Text1").value = "";
else this.getField("Text1").value = "123";

Likes

translate

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
Most Valuable Participant ,
Mar 25, 2021 Mar 25, 2021

Copy link to clipboard

Copied

This seems unnecessarily complicated. Why not simply use a check-box, instead?

Likes

translate

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 ,
Mar 25, 2021 Mar 25, 2021

Copy link to clipboard

Copied

Thank you Nesa, you have provided the perfect result.  Comibined with your other tip it works very well.  Much appreciated.

Likes

translate

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 ,
Apr 04, 2021 Apr 04, 2021

Copy link to clipboard

Copied

The above script works well to toggle a text string into a separate textbox from a button. If I have different buttons that perform the same function to different textboxes, I can then merge all those "button selected" text strings into a single text box.  I was wondering if there might be a way of removing the separate textboxes and just have all the different buttons populate the same textbox.  If I try performing this using the above script, when I toggle the button it clears all the text strings from the textbox rather than just "its" text string.

 

I know this is easily achieved using a checkbox rather than a button but I just thought I'd put out the question as it would remove alot of hidden textboxes from my form.

Likes

translate

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