I am trying to save the timestamp from a click in a database on Otree. I tried using differents codes.
The first one is this
function myFunction() {
var n = Date.now();
document.getElementById("demo").innerHTML = n;
}
document.getElementById('n').value;
I put the next code in the html:
<p style="text-align: center;"><button class="btn btn-primary btn-large" onclick="myFunction()" name="offer_accepted" value="True"> A</button> <button class="btn btn-primary btn-large" onclick="myFunction()" name="offer_accepted" value="False">B</button></p>
The next one is this:
function record_current_time(){
var current_time = new Date();
current_time = current_time.getTime()
document.getElementById("id_currentTime").setAttribute("value", current_time)
}
window.onload = record_current_time;
And put the next code in my html:
<input type="hidden" name="currentTime" id="id_currentTime"/>
In both cases I don't get anything in my database.
Can someone help me
{% formfield player.currentTime %}) rather than hard-coding it? How is the form submitted?