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?
Try this code:
if(this.getField("Text1").value != "")
this.getField("Text1").value = "";
else this.getField("Text1").value = "123";
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.
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?
Copy link to clipboard
Copied
You need to tell us what exactly you trying to achive?
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?
Copy link to clipboard
Copied
That would work. How to I populate a hidden text field with a value when a button is clicked?
Copy link to clipboard
Copied
As the MouseUp event of the button enter this code:
this.getField("Text1").value = "123";
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?
Copy link to clipboard
Copied
Try this code:
if(this.getField("Text1").value != "")
this.getField("Text1").value = "";
else this.getField("Text1").value = "123";
Copy link to clipboard
Copied
This seems unnecessarily complicated. Why not simply use a check-box, instead?
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.
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.