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.
Thank you for your advice. Could you please give me an example of what script would need to be used to perform this?
You need to tell us what exactly you trying to achive?
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?
That would work. How to I populate a hidden text field with a value when a button is clicked?
As the MouseUp event of the button enter this code:
this.getField("Text1").value = "123";
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";
This seems unnecessarily complicated. Why not simply use a check-box, instead?
Thank you Nesa, you have provided the perfect result. Comibined with your other tip it works very well. Much appreciated.
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.