Welcome to the LimeSurvey Community Forum

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

has ls date range question?

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 years 10 months ago #120232 by tpartner
Replied by tpartner on topic has ls date range question?
This script will handle text inputs in an array-texts type question:

Code:
<script type="text/javascript" charset="utf-8">  
 
  $(document).ready(function() {  
 
    // Identify some elements
    var thisQuestion = $('#question{QID}');
 
    var surveyRoot = location.pathname.split('index.php')[0];
 
    // Define the timepicker    
    function insertPickers() {
      $('tr.subquestion-list', thisQuestion).each(function(i) {
        var startDateTextBox = $('input[type="text"]:eq(0)', this);
        var endDateTextBox = $('input[type="text"]:eq(1)', this);
 
        $.timepicker.datetimeRange(
          startDateTextBox,
          endDateTextBox,
          {
            minInterval: (1000*60*60), // 1hr
            dateFormat: 'dd M yy', 
            timeFormat: 'HH:mm',
            start: { }, // start picker options
            end: { } // end picker options          
          }
        );
      });
    }
 
    // Insert the timepickers
    if (!$.isFunction($.fn.timepicker)) {      
      $('head link[rel="stylesheet"]').last().after('<link rel="stylesheet" href="'+surveyRoot+'third_party/jquery-ui-timepicker-addon/jquery-ui-timepicker-addon.css" type="text/css" media="screen">');
      $.getScript( surveyRoot+'third_party/jquery-ui-timepicker-addon/jquery-ui-timepicker-addon.js', function( data, textStatus, jqxhr ) {
        insertPickers();
      });
    }
    else {  
      insertPickers();
    }
  });
</script>

Sample survey attached.

File Attachment:

File Name: limesurvey...6224.lss
File Size:16 KB

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: Ben_V
The topic has been locked.
More
8 years 10 months ago #120234 by Ben_V
Replied by Ben_V on topic has ls date range question?
Hi Tony,
very useful for users looking for a check-in / check-out "booking" question type ;)

Benoît

EM Variables => bit.ly/1TKQyNu | EM Roadmap => bit.ly/1UTrOB4
Last Releases => 2.6x.x goo.gl/ztWfIV | 2.06/2.6.x => bit.ly/1Qv44A1
Demo Surveys => goo.gl/HuR6Xe (already included in /docs/demosurveys)
The topic has been locked.
  • iscar
  • iscar's Avatar Topic Author
  • Offline
  • Elite Member
  • Elite Member
More
8 years 10 months ago #120236 by iscar
Replied by iscar on topic has ls date range question?
thanks for tpartner replay.
the problem is js has no date calculation function then i need to turn the date into timestamp.
tried altfield option,how to use @ to record the date as timestamp and let input display the date?
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose