Which button has been clicked?
Hi all,
my question is pretty easy and I know you know how to answer!
I created a Form with 12 buttons and I need to provide a feedback according to which buttun my subject clicked. I need to store in a variable an integer corresponding to the clicked button (1 to 12).
How can I achieve this?
Thanks!
marco
Comments
Hi Marco,
Every button widget has a `var` keyword that you can use to specify what the variable should be for that button. For example, `button1`. If you do this for each button, one of them will receive the value `yes` whereas the other ones will be `no`. So once a form has been run, you just need to read all the button variables and determine which one of them is yes.
Does that make sense?
https://osdoc.cogsci.nl/3.2/manual/forms/variables/#button
Eduard
Hi Eduard,
thank you for your help! You pointed me in the right direction!
By using the "var" keyword, I was able to achieve what I needed. The problem was that the form returned the text in the specific button (that for experimental needs was just a random label) but setting different "vars" I was able to trace which button was clicked.
Thank you again!
marco