| Reference | Downloads | Github

Demonstrate the slider value

Hi all,

I have a silly question.
I want my participants to see the numerical value when they use the slider component.
I have a text component with the following:

And it works. But at the beginning of each trial, instead of numbers I see “Hello world” message. When I start using the slider, it disappears and the numerical values appear, as they should. Is there a way to delete this “Hello world” message in the beginning of the trial?

Hey! Thanks for the warning; we already encountered a similar problem with polygons, which I made an issue for on the PsychoJS GitHub. I added a link to your post to say it’s probably also happening for text stimuli: Use variable in the size of VisualStim -> First frame it's default size · Issue #293 · psychopy/psychojs · GitHub

For a workaround, see: Experiment uploaded to Pavlovia has brief black spots and after-images from previous trials - #3 by DavidBrocker (in your case, set the text property of a textbox to some value, like " ", in the Begin Routine tab of a code component).

Thanks a lot!
I added the following code in the Begin Routine:

text_4.text=" "

My text component is called text_4. However, nothing changed and I still have the Hello world message for some reason.

Is your code component above the text component?

Thanks! Yes, it was. But “Hello world” is still displayed.

Try text_4.setText(" ")

Alternatively, you could expose the text_4 component to your browser, then you can try things out in the console. See this tutorial to find out how: Thomas Pronk / demo_expose_js · GitLab

For some reason text_4.setText(" ") did not work either…
Thanks, I’ll check out the console!

K, good luck! If you’re still stuck after that, feel free to make me a maintainer for you gitlab project with me, so I can take a look. I’m tpronk

1 Like

Hi There,

Does this do something similar to what you need?

If yes you can access that here: Files · master · Rebecca Hirst / fancy_slider_test · GitLab

in javascript you need to get the current marker position using (getRating doesn’t work in psychojs):

thisPos = slider._markerPos

you can then use thisPos as the rating - but since a marker is not created untill a response has been made this is initially undefined, so you first need to use:

if (typeof slider._markerPos !== 'undefined') {
    thisPos = slider._markerPos;

hope this helps

1 Like

Thank you both very much!

Thanks a lot Becca, it works perfectly!

Ahaaaaa… thanks @Becca! Now I get it: when setting the value of the text to undefined it reverts to it’s default value, which is “Hello world”. Perhaps we should change the default value to something different?