Default Value for Slider without anchoring

682 views
Skip to first unread message

Bennett Smith-Worthington

unread,
Jul 1, 2021, 4:29:29 PM7/1/21
to oTree help & discussion
Hi everyone, 
I have a slider without an anchor (as shown here: https://gitlab.com/gr0ssmann/otree_slider/-/blob/main/SliderPage.html), and I am trying to figure out how to define a default value for the slider when the user does not give an input.
To be a bit more clear, we have a slider which acts as the answer field for a user who is asked a question; the slider has values ranging from 0 to 100. But the default value that is returned to the field is 50 when no input is given; ; this is a problem, since we will not be able to tell the difference between someone who answered 50 and someone who simply did not answer. 
So, I am hoping to make the default value something outside of the possible range of answers (like -1 or -5) or 'none' value. Again, the range we have now is 0 - 100, and I would like to make it so that it is easy to identify and then censor the values that come from a user not inputting an answer. 
Does anyone have any idea about how to do this? I'd really appreciate any thoughts on this topic! I've attached the code below (it's very similar to the link above, as that's the template I followed.)
Thanks very much,
Bennett 

Slider.html

Chris @ oTree

unread,
Jul 1, 2021, 4:40:58 PM7/1/21
to Bennett Smith-Worthington, oTree help & discussion
You could use javascript that does not let the user proceed unless they touched the slider. Use the oninput/onchange event to set a variable, and reject form submission if that variable was not set. 

Sent from my phone

On Jul 1, 2021, at 2:29 PM, Bennett Smith-Worthington <bs3...@columbia.edu> wrote:


--
You received this message because you are subscribed to the Google Groups "oTree help & discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to otree+un...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/otree/f94cd731-021b-423c-8fae-b4bca7b31c41n%40googlegroups.com.
<Slider.html>

Bennett Smith-Worthington

unread,
Jul 1, 2021, 10:10:56 PM7/1/21
to oTree help & discussion
Thanks Chris, I'll give this a shot!! 
Thanks,
Bennett

Max R. P. Grossmann

unread,
Jul 2, 2021, 5:21:40 AM7/2/21
to Bennett Smith-Worthington, oTree help & discussion
Hi Bennett,

Author here. Have you considered setting value="-1" of the hidden field
in line 115
(https://gitlab.com/gr0ssmann/otree_slider/-/blob/main/SliderPage.html#L115)?
If the slider is never touched, this will be what is submitted.

Alternatively, you could set the initial parameter of the form field in
your models.py.

Best,

Max


On 01/07/2021 22:29, Bennett Smith-Worthington wrote:
> Hi everyone,
> I have a slider without an anchor (as shown here:
> https://gitlab.com/gr0ssmann/otree_slider/-/blob/main/SliderPage.html
> <https://gitlab.com/gr0ssmann/otree_slider/-/blob/main/SliderPage.html>),
Reply all
Reply to author
Forward
0 new messages