Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Adding a time stamp in a list with comment question and hiding the comment

  • midnightking
  • midnightking's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
3 years 5 months ago #207491 by midnightking
Hello, I have recently had success creating time stamps in short text questions using the script below. I was wondering however, if it were possible to modify such a script for a List with comment question. The date would be stored in the text area of the comment, but it would be hidden to the participants using Javascript. However survey admins would have the date in the output.

Does this make sense ?

<script>
$(document).ready(function(){
if($('#question{QID} input:text:eq(0)').val() == '') {
$('#question{QID} input:text:eq(0)').val(new Date());
}
{
$('#question{QID}').hide();
}
});
</script>
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Online
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 5 months ago #207518 by tpartner
This will load the textarea with a timestamp:

Code:
<script type="text/javascript" charset="utf-8">
 
  $(document).on('ready pjax:scriptcomplete',function(){
 
    if($.trim($('#question{QID} textarea:eq(0)').val()) == '') {
      $('#question{QID} textarea:eq(0)').val(new Date());
    }
    $('#question{QID} .answers-list').removeClass('col-sm-6');
    $('#question{QID} .text-item').hide();
  });
</script>

Sample survey attached:

File Attachment:

File Name: limesurvey...1(1).lss
File Size:19 KB

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose