Implementing a raw HTML slider

232 views
Skip to first unread message

Sarah-Luise Grimm

unread,
Aug 12, 2021, 8:03:21 AM8/12/21
to oTree help & discussion

Dear all,

I am relatively new to otree and don't quite understand how to implement a raw html slider. I have taken an example from https://otree.readthedocs.io/en/latest/forms.html#raw-html-widgets.
With this I manage to implement my slider, the only problem is that the result is not displayed in the data section of otree.
In order to fix it I implemented an equal variable in my python script as "environment= models.IntegerField()". Then did not add the variable environment as form fields for the page, as this would have led to duplication.
Unfortunately, none of this works.
Does anyone have an idea how to solve this problem? I am attaching a photo of the html code.

Thanks a lot,
Sarah

HTML_Problem.PNG


Chris @ oTree

unread,
Aug 12, 2021, 12:29:03 PM8/12/21
to oTree help & discussion
you always need to specify all fields in the page's form_fields, even if you are already using its name in the template. (There are several reasons for this.)

Sarah-Luise Grimm

unread,
Aug 12, 2021, 12:45:25 PM8/12/21
to oTree help & discussion
Thanks for your reply!

I tried so, but when doing so, I still do not get the data in the otree output storage.
Furthermore, it seems like I can not drop the variable 'environment' as it appears again when running the cod.

I attached you two pictures.
HTML_problem_3.PNG
HTML_problem_2.PNG

Chris @ oTree

unread,
Aug 12, 2021, 1:04:58 PM8/12/21
to oTree help & discussion
i would need to see more of your code (player model and template) but it looks like you have the 'environment' field twice in your template, once as a hidden input and the other as a slider. by the way the slider looks weird in the screenshot; doesn't look like a normal slider with a thin horizontal line.
Reply all
Reply to author
Forward
0 new messages