- Posts: 31
- Thank you received: 1
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}'); // Listener on the radios $('tr.subquestions-list input[type="radio"]', thisQuestion).click(function(event) { var thisRow = $(this).closest('tr.subquestions-list'); $('input[type="text"]', thisRow).val(''); }); // Keyup listener on the text inputs $('tr.subquestions-list input[type="text"]', thisQuestion).keyup(function(event) { if($(this).val() != ''){ var thisRow = $(this).closest('tr.subquestions-list'); $('input[type="radio"]', thisRow).attr('checked', false); } }); // Paste listener on the text inputs $('tr.subquestions-list input[type="text"]', thisQuestion).bind('paste', function () { var thisInput = $(this); setTimeout(function() { // Little timeout so the val() is available if($(thisInput).val() != ''){ var thisRow = $(thisInput).closest('tr.subquestions-list'); $('input[type="radio"]', thisRow).attr('checked', false); } }, 100); }); }); </script>
<script type="text/javascript" charset="utf-8"> $(document).ready(function(){ // Identify this question var thisQuestion = $('#question{QID}'); // Listener on the radois $('tr.subquestions-list input[type="radio"]', thisQuestion).click(function(event) { var thisRow = $(this).closest('tr.subquestions-list'); $('input[type="text"]', thisRow).val(''); }); // Keyup listener on the text inputs $('tr.subquestions-list input[type="text"]', thisQuestion).keyup(function(event) { if($(this).val() != ''){ var thisRow = $(this).closest('tr.subquestions-list'); $('input[type="radio"]', thisRow).prop('checked', false); } }); // Paste listener on the text inputs $('tr.subquestions-list input[type="text"]', thisQuestion).bind('paste', function () { var thisInput = $(this); setTimeout(function() { // Little timeout so the val() is available if($(thisInput).val() != ''){ var thisRow = $(thisInput).closest('tr.subquestions-list'); $('input[type="radio"]', thisRow).prop('checked', false); } }, 100); }); }); </script>
<script type="text/javascript" charset="utf-8"> $(document).ready(function(){ // Identify this question var thisQuestion = $('#question{QID}'); // Listener on the radois $('tr.subquestions-list input[type="radio"]', thisQuestion).click(function(event) { var thisRow = $(this).closest('tr.subquestions-list'); $('input[type="text"]', thisRow).val(''); // Check conditions... $('input[type="text"]', thisRow).each(function(i) { fixnum_checkconditions($(this).attr('value'), $(this).attr('name'), $(this).attr('type')); }); }); // Keyup listener on the text inputs $('tr.subquestions-list input[type="text"]', thisQuestion).keyup(function(event) { if($(this).val() != ''){ var thisRow = $(this).closest('tr.subquestions-list'); $('input[type="radio"]', thisRow).prop('checked', false); } }); // Paste listener on the text inputs $('tr.subquestions-list input[type="text"]', thisQuestion).bind('paste', function () { var thisInput = $(this); setTimeout(function() { // Little timeout so the val() is available if($(thisInput).val() != ''){ var thisRow = $(thisInput).closest('tr.subquestions-list'); $('input[type="radio"]', thisRow).prop('checked', false); } }, 100); }); }); </script>
<script type="text/javascript" charset="utf-8">$(document).ready(function() { // Identify this question var qID = {QID}; var thisQuestion = $('#question'+qID); // Define the select element (radio) var select1 = '<div id="insertedRadio"> \ <input type="radio" title="ans_1" value="1" name="Radio1" /> \ </div>'; var select2 = '<div id="insertedRadio"> \ <input type="radio" title="ans_2" value="2" name="Radio1" /> \ </div>'; // Hide the text inputs $('#question'+qID+' .answer_cell_005 input[type="text"]').addClass('hidden').hide(); $('#question'+qID+' .answer_cell_006 input[type="text"]').addClass('hidden').hide(); // Insert the select elements $('#question'+qID+' .answer_cell_005').append(select1); $('#question'+qID+' .answer_cell_006').append(select2); // Listener on the radios $('tr.subquestions-list input[type="radio"]', thisQuestion).click(function(event) { var thisRow = $(this).closest('tr.subquestions-list'); var thisCell = $(this).closest('td.question-item'); var thisTextInput = $('input[type="text"]', thisCell); $('input[type="text"]', thisRow).val(''); $('input[type="text"]', thisCell).val($(this).attr('value')); // Check conditions... checkThisRowConditions(thisRow) }); // Keyup listener on the text inputs $('tr.subquestions-list input[type="text"]', thisQuestion).keyup(function(event) { if($(this).val() != ''){ var thisRow = $(this).closest('tr.subquestions-list'); $('input[type="radio"]', thisRow).attr('checked', false); $('input[type="text"].hidden', thisRow).val(''); // Check conditions... checkThisRowConditions(thisRow) } }); // Paste listener on the text inputs $('tr.subquestions-list input[type="text"]', thisQuestion).bind('paste', function () { var thisInput = $(this); setTimeout(function() { // Little timeout so the val() is available if($(thisInput).val() != ''){ var thisRow = $(thisInput).closest('tr.subquestions-list'); $('input[type="radio"]', thisRow).attr('checked', false); $('input[type="text"].hidden', thisRow).val(''); // Check conditions... checkThisRowConditions(thisRow) } }, 100); }); function checkThisRowConditions(thisRow) { $('input[type="text"]', thisRow).each(function(i) { fixnum_checkconditions($(this).attr('value'), $(this).attr('name'), $(this).attr('type')); }); } }); </script>