- Posts: 2
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Save data from js to results
- Sonjawnklr
- Topic Author
- Offline
- New Member
Less
More
2 years 9 months ago #217511
by Sonjawnklr
Save data from js to results was created by Sonjawnklr
Hello everybody,
I have some audioplayback, where the participant is promped to press the spacebar a varying amount of times. I can already log the total number of presses to the console.
Is it possible to save that to the results file somehow?
Below is my WIP code:
I would like to log the count to the results file as a variable in the vid.onended function (see comment).
Thank you very much for your help!
I have some audioplayback, where the participant is promped to press the spacebar a varying amount of times. I can already log the total number of presses to the console.
Is it possible to save that to the results file somehow?
Below is my WIP code:
Code:
<div style="text-align: center;"><img alt="" src="/limesurvey-wipsy/upload/surveys/623622/images/Anleitung.JPG" style="width: 800px;" /></div> <div class="ckeditor-html5-video" style="text-align:center;"> <video controls="controls" controlslist="nodownload" id="vid" src="/limesurvey-wipsy/upload/surveys/623622/files/Achtsamkeits%C3%BCbung.mp3"> </video> </div> <script> $(document).ready(function() { $('#ls-button-submit').hide(); var vid = document.getElementById('vid'); var count = 0; vid.onplay = function() { document.getElementById('vid').style.visibility = "hidden"; document.body.onkeyup = function(e){ if(e.keyCode == 32){ console.log(count++); }; }; }; vid.onended = function() { $('#ls-button-submit').show().trigger('click'); // Send total count to results! console.log(count) } }); </script>
I would like to log the count to the results file as a variable in the vid.onended function (see comment).
Thank you very much for your help!
The topic has been locked.
- tpartner
- Away
- LimeSurvey Community Team
Less
More
- Posts: 10633
- Thank you received: 3697
2 years 9 months ago #217520
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Save data from js to results
If your script is in the text of a short-text type question:
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- Sonjawnklr
- Topic Author
- Offline
- New Member
Less
More
- Posts: 2
- Thank you received: 0
2 years 9 months ago #217535
by Sonjawnklr
Replied by Sonjawnklr on topic Save data from js to results
Hey,
thanks for your quick response. That worked perfectly. I also hid the text field, so the participant won't notice it.
thanks for your quick response. That worked perfectly. I also hid the text field, so the participant won't notice it.
The topic has been locked.