How to detect Radio Button change or entry for validation?

Hi everyone.

I am trying to deploy what is essentially a form (tried the Beta Form component but it displayed too wierdly on-line) and eventually stumbled across the ‘Radio Button’ setting of the slider. Yay! And this is a non-beta object so should work predictably. This will be very useful. BUT…

I would like to only show the ‘continue’ button once participants have selected responses for the sliders currently on-screen. Have looked at the doco and can’t find any kind of events that interacting with this object might raise. So… I had a go at hacking something up myself (below)… and this works locally, but not on Pavlovia.

Screen Shot 2022-01-28 at 10.13.52 pm

There must be an accepted way of doing this. Surely people have done exactly this thing before.

Any suggestions on what code to include that I can use to reveal this button once a user has clicked on a slide value?

Thanks.

D.

Hi there :slight_smile: I believe this is what you need Using Sliders in PsychoPy (with "Pop Up" Submit Buttons) - YouTube

2 Likes

Hi @suelynnmah!

Thanks so much for pointing this out to me! Much appreciated! :slight_smile:

Unfortunately this won’t solve my particular proplem since I have two sliders on screen and need some logic to determine when BOTH have recieved input. :frowning:

Hoping to hear from you at some point so I can move forward.

Thanks again though!

D.

Hi Dan, for multiple sliders, you just need to use “and”. So for example, in the condition field, you just type Q1_Response.rating and Q2_Response.rating

So I’ve been playing around with this some more this morning. And I seem to have identified a situation where attributes of the slider object (or my code) perform different locally than when deployed to Pavlovia.

I was wondering if the ‘undefined error’ above was due to the order of components (top to bottom) and trying to read a value from a component that hadn’t been created yet - so I copied the ‘Each Frame’ code that interrogates the sliders into a new code component and stuck this below the sliders. This seems to have fixed the problem I had above BUT…

Now - when I run the experiment locally, the <Slidername>.rating variable seems to recieve different values when run locally than on-line.

Locally - it appears that this variable is ‘none’ until I click on a value (see the Stdout box in the image below:

Whereas on Pavlovia, running the same code seems to end up with the variable having some form of value - immediately and without any user input (and immediately instantiates my ‘continue’ button). See console output below.

Baffling.

So I am still looking for a way by which I can programmatically (and reliably) detect user input into each of these two sliders, and then show a ‘continue’ button both locally and on Pavlovia when both have responses.

Getting a bit desperate over here now. :frowning:

Thanks for any advice.

D.

Hi Dan,

I hope you don’t mind I’ve removes direct tags to myself and wake, as we try to avoid tagging team members unless 100% necessary (this opens the space for others to have the chance to offer guidance).

Sue Lynn is actually correct in that if you have two sliders with a pop up button appearing when both sliders have a rating, you don’t need any code components. You can just have the “start” field of your button be

slider1.rating and slider2.rating

if that doesn’t work for online use try using

slider1.rating && slider2.rating

if this is causing a problem I suspect it may be because you have “0” as a possible tick on your slider, try using tick values that are greater than 0 only.

Hope this helps,
Becca

Hi Sue and Becca!

Thanks so much - this now works and using the conditional within the button component - rather than coding it - is SO MUCH SIMPLER! I have managed to remove soooooo much code that now that I know this.

(I was previously unaware of the dropdown window in the ‘Start’ field - this adds so much flexibility - that I don’t have to code for.)

Thanks so much for both your help here. Life-savers!

:slight_smile:

D.

1 Like