Skip to main content
Known Participant
March 25, 2021
Answered

Text field or Export Value for Button

  • March 25, 2021
  • 2 replies
  • 1896 views

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?

This topic has been closed for replies.
Correct answer Nesa Nurani

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


Try this code:

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

2 replies

try67
Community Expert
Community Expert
March 25, 2021

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?

Known Participant
March 25, 2021

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

try67
Community Expert
Community Expert
March 25, 2021

As the MouseUp event of the button enter this code:

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

ls_rbls
Community Expert
Community Expert
March 25, 2021

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.

Known Participant
March 25, 2021

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

Inspiring
March 25, 2021

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