Hi,
it's always better to provide e lss export of these relevant question.
Then you avoid the typo here
var timestamps = ;
instead of
var timestamps = ;
Now, what can you do?
My idea is to use a question of type"multiple short text" with two subquestions.
1. The timestamps
2. The count of timestamps
Then you may use this - slightly adapted - script.
Code:
<div id="buttonplacement">
<button id="tapbutton" type="button">TAP</button>
</div>
Code:
<script type="text/javascript" data-author="Tony Partner">
$(document).on('ready pjax:scriptcomplete',function(){
// Identify this question
var thisQuestion = $('#question{QID}');
var thisTextarea = $('input[type=text]:eq(0)', thisQuestion);
var thisCountarea = $('input[type=text]:eq(1)', thisQuestion);
var timestamps = [];
if($.trim($(thisTextarea).val()) != '') {
timestamps = $.trim($(thisTextarea).val()),split(',');
}
// Listener on the button
$('#tapbutton').on('click', function(e) {
var newTimeStamp = Date.now();
timestamps.push(newTimeStamp);
$(thisCountarea).val(timestamps.length);
$(thisTextarea).val(timestamps).trigger('keyup');
});
});
</script>
And some styling
Code:
<style type="text/css">#question{QID} .answer-container {
display: none;
}
#buttonplacement {
text-align: center;
}
</style>
You will get this
Joffm