- Posts: 136
- Thank you received: 37
Ask the community, share ideas, and connect with other LimeSurvey users!
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { // Identify this question var thisQuestion = $('#question{QID}'); // Interrupt the Next/Submit click $('#movenextbtn, #movesubmitbtn').bind('click', function () { var unanswered = false; // Loop through all text inputs $('input.text', thisQuestion).each(function(i) { var thisValue = $(this).val(); if(thisValue == '') { unanswered = true; } }); // Pop up confirm if we found an unanswered item var cont = true; if(unanswered == true) { cont = confirm('You have an unanswered item.\nDo you want to continue?'); } return cont; }); }); </script>
Keep the phone in the pocket, too. Have a nice weekend.tpartner wrote: I don't have a computer with me this weekend and writing code on my phone is not one of my strengths
Is that code able to check if two sliders on a Multiple numerical input question are untouched?
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { // Apply the handleSliders() function to this question handleSliders($('#question{QID}')); }); function handleSliders(thisQuestion) { // Identify and hide the hidden question var qHidden = $(thisQuestion).nextAll('.multiple-short-txt:eq(0)'); $(qHidden).hide(); // Initial classes on the slider sub-question items (rows) $('li.question-item', thisQuestion).addClass('slider-unmoved'); $('input.text', qHidden).each(function(i) { if($(this).val() == 1) { $('li.question-item:eq('+i+')', thisQuestion).removeClass('slider-unmoved').addClass('slider-moved'); } }); // Listener on the sliders $('.ui-slider', thisQuestion).on('slidechange', function(event, ui) { var thisRow = $(this).closest('li.question-item'); var thisRowIndex = $('li.question-item', $(this).closest('ul.questions-list')).index(thisRow); // Set the value in the hidden question if($('input.text', thisRow).val() != '') { thisRow.removeClass('slider-unmoved').addClass('slider-moved'); $('input.text:eq('+thisRowIndex+')', qHidden).val(1); } }); // Interrupt the Next/Submit click $('#movenextbtn, #movesubmitbtn').bind('click', function () { // Pop up confirm if we found an unmoved slider // Pop up only occurs once and only if the page has not been previously visited var cont = true; if($('.slider-unmoved', thisQuestion).length > 0 && $('input.text:last', qHidden).val() != 1) { $('.slider-unmoved', thisQuestion).addClass('highlight'); cont = confirm('You have an unanswered item(s).\nDo you want to continue?'); } $('input.text:last', qHidden).val(1); return cont; }); } </script>
li.slider-unmoved.highlight .slider-label { background: pink; }
This is actually not very complicated so only a few minutes - it takes almost as long to create the test survey as to write the script.This looks very sophisticated....Would you mind to tell me how much time do you invest for such a solution?
Sorry, I don't feel this is the place to discuss my work experience. I, unlike some other people, am not here to sell my services or products.One question: Which other survey tools do you use or have used in the past?