# Demonstrate the slider value

**URL:** <https://discourse.psychopy.org/t/demonstrate-the-slider-value/22767>\
**Category:** Online experiments\
**Created:** [May 4, 2021, 3:47pm UTC](https://discourse.psychopy.org/t/demonstrate-the-slider-value/22767 "2021-05-04T15:47:42Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![MarinaIosifian](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/marinaiosifian/32/7507_2.png) [@MarinaIosifian](https://discourse.psychopy.org/u/MarinaIosifian)\
**Post date:** [May 4, 2021, 3:47pm UTC](https://discourse.psychopy.org/t/demonstrate-the-slider-value/22767/1 "2021-05-04T15:47:42Z")

</div>

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:  
$slider.getRating()

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?

---

<div class="post-metadata">

**Author:** ![thomas\_pronk](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/thomas_pronk/32/9531_2.png) [@thomas\_pronk](https://discourse.psychopy.org/u/thomas_pronk)\
**Post date:** [May 4, 2021, 4:21pm UTC](https://discourse.psychopy.org/t/demonstrate-the-slider-value/22767/2 "2021-05-04T16:21:47Z")

</div>

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](https://github.com/psychopy/psychojs/issues/293)

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

---

<div class="post-metadata">

**Author:** ![MarinaIosifian](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/marinaiosifian/32/7507_2.png) [@MarinaIosifian](https://discourse.psychopy.org/u/MarinaIosifian)\
**Post date:** [May 4, 2021, 7:27pm UTC](https://discourse.psychopy.org/t/demonstrate-the-slider-value/22767/3 "2021-05-04T19:27:52Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [May 4, 2021, 7:36pm UTC](https://discourse.psychopy.org/t/demonstrate-the-slider-value/22767/4 "2021-05-04T19:36:46Z")

</div>

Is your code component above the text component?

---

<div class="post-metadata">

**Author:** ![MarinaIosifian](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/marinaiosifian/32/7507_2.png) [@MarinaIosifian](https://discourse.psychopy.org/u/MarinaIosifian)\
**Post date:** [May 4, 2021, 7:50pm UTC](https://discourse.psychopy.org/t/demonstrate-the-slider-value/22767/5 "2021-05-04T19:50:04Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![thomas\_pronk](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/thomas_pronk/32/9531_2.png) [@thomas\_pronk](https://discourse.psychopy.org/u/thomas_pronk)\
**Post date:** [May 4, 2021, 10:13pm UTC](https://discourse.psychopy.org/t/demonstrate-the-slider-value/22767/6 "2021-05-04T22:13:42Z")

</div>

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](https://gitlab.pavlovia.org/tpronk/demo_expose_js)

---

<div class="post-metadata">

**Author:** ![MarinaIosifian](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/marinaiosifian/32/7507_2.png) [@MarinaIosifian](https://discourse.psychopy.org/u/MarinaIosifian)\
**Post date:** [May 5, 2021, 2:03pm UTC](https://discourse.psychopy.org/t/demonstrate-the-slider-value/22767/7 "2021-05-05T14:03:04Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![thomas\_pronk](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/thomas_pronk/32/9531_2.png) [@thomas\_pronk](https://discourse.psychopy.org/u/thomas_pronk)\
**Post date:** [May 5, 2021, 2:07pm UTC](https://discourse.psychopy.org/t/demonstrate-the-slider-value/22767/8 "2021-05-05T14:07:23Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Becca](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/becca/32/34260_2.png) [@Becca](https://discourse.psychopy.org/u/Becca)\
**Post date:** [May 5, 2021, 2:32pm UTC](https://discourse.psychopy.org/t/demonstrate-the-slider-value/22767/9 "2021-05-05T14:32:24Z")

</div>

Hi There,

Does this do something similar to what you need? [https://run.pavlovia.org/lpxrh6/fancy\_slider\_test](https://run.pavlovia.org/lpxrh6/fancy_slider_test)

If yes you can access that here: [Files · master · Rebecca Hirst / fancy\_slider\_test · GitLab](https://gitlab.pavlovia.org/lpxrh6/fancy_slider_test/tree/master)

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

```auto
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:

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

```

hope this helps  
Becca

---

<div class="post-metadata">

**Author:** ![MarinaIosifian](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/marinaiosifian/32/7507_2.png) [@MarinaIosifian](https://discourse.psychopy.org/u/MarinaIosifian)\
**Post date:** [May 5, 2021, 2:53pm UTC](https://discourse.psychopy.org/t/demonstrate-the-slider-value/22767/10 "2021-05-05T14:53:19Z")

</div>

Thank you both very much!

Thanks a lot Becca, it works perfectly!

---

<div class="post-metadata">

**Author:** ![thomas\_pronk](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/thomas_pronk/32/9531_2.png) [@thomas\_pronk](https://discourse.psychopy.org/u/thomas_pronk)\
**Post date:** [May 5, 2021, 2:58pm UTC](https://discourse.psychopy.org/t/demonstrate-the-slider-value/22767/11 "2021-05-05T14:58:32Z")

</div>

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?
