Form fields automatically refilled with the previously inputted number

145 views
Skip to first unread message

Charlie Babe

unread,
Aug 1, 2021, 7:24:15 PM8/1/21
to oTree help & discussion

Hi everyone,

I have a page with some form fields I need participants to input. The page will repeat for three times. But each time after the participants input some number, the next time the form fields automatically refilled with the inputted number from the previous time. I am wondering if there is a way to clear form fields after the submission. The screenshot is as follows:

Capture.PNG

Thanks!

Best.

Charlie

Shiyu ZHANG

unread,
Aug 3, 2021, 1:37:21 AM8/3/21
to oTree help & discussion
Hi Charlie,

   If you are referring to the case that the numbers remain in the form when participants move to the next page. One way I would try to handle this issue is to add some javascript code that clears the form input: 1)On the web page you take the screenshot with, right-click the form fields and choose Inspect, then you shall find the id of the form field, for example, it may look like ' <input type="number" id="B_share" ....">' and its id is 'B_share' in this case; 2) Add the following line of code to your script block:  document.getElementById("B_share").value =""; it shall be able to clear the form filed when the new page is loaded. 

  If you are referring to the form autofill feature of the browser, e.g., previously I input number '123', the next time I input '1', the remaining '23' pops up, I am not sure whether there is a way to stop this function on the others' browsers.

  Hope this helps.

Best,
Jake 

Shiyu ZHANG

unread,
Aug 5, 2021, 3:38:49 AM8/5/21
to oTree help & discussion
Hi Charlie,

  As for the second case of autofill, I actually find the technique here: HTML <form> autocomplete Attribute, and I also found that this shall not be the concern for most of us, as O-Tree already takes care of it and set the attribute to be 'off' by default, for example, here is the form tag for O-Tree forms: <form class="otree-form" method="post" role="form" id="form" autocomplete="off".

Best,
Jake
On Monday, 2 August 2021 at 07:24:15 UTC+8 xu00...@gmail.com wrote:
Reply all
Reply to author
Forward
0 new messages