Issue with conditionally showing buttons online

OS (e.g. Win10): Windows 11
PsychoPy version (e.g. 2024.2.4 Py 3.8): v2025.1.1
Standard Standalone Installation? Yes
Do you want it to also run online? Yes
What are you trying to achieve?:

I am trying to conditionally show a button depending on whether text has been typed into a textbox component. Unless something has been typed, I want the button to move on to be hidden, as to encourage people to fill out the box. Having nothing entered messes with a lot of my experiment functionality.

What did you try to make it work?:

I presently use the following code in an Each Frame code component, where Response.text is my textbox. I then set the start time for Response to have the condition of Show.

if Response.text != "":
    Show = True
else:
    Show = False

This works great when running offline, but not online via Pavlovia, where the textbox just stays visible no matter what, which isn’t great. If it’s useful, this is what the above code converts to in Javascript:

if ((Response.text !== "")) {
    Show = true;
} else {
    Show = false;
}

I have also noticed that the button remains if someone deletes the text that was there, so it is still technically possible to submit a blank textbox. If there’s a more elegant way to force a response in order to submit, I would be grateful! I realise it’s unlikely a participant will type, delete and press submit, but I have also seen some odd participant behaviour before…

Link to the most relevant existing thread you have found: I thus far haven’t been able to find a thread where a similar issue is occurring, but I will keep looking!

Thank you :slight_smile:

I have solved at least one part of the issue - I didn’t notice that this actually worked fine for my first set of trials, but the button automatically appeared for a second phase later on. The issue appears to be that by using the name Show for every phase, Show was still set to 1 at the very start of the next phase. By changing the name to something different it seems to have fixed that issue.

However, I am still wondering if there’s a more elegant way to force a response.