- Posts: 10269
- Thank you received: 3648
Ask the community, share ideas, and connect with other LimeSurvey users!
It works fine for me in citronade. Have you added any other JavaScript? Any JavaScript errors?Unfortunately, the second version (add reset button for the whole question) does not work with me.
Yeah, Denis is correct, if using citronade, you need too change the table-layout rule:Using my layout, you have to scroll to access the reset button.
<script type="text/javascript" charset="utf-8"> $(document).ready(function(){ addReset('{QID}'); function addReset(qID) { $('#question'+qID+' table.subquestions-list').css('table-layout', 'auto'); $('#question'+qID+' table.subquestions-list thead tr').append('<th />'); $('#question'+qID+' tr.answers-list').append('<td class="buttonCell"><input type="button" value="Reset" class="resetButton" /></td>'); $('#question'+qID+' .resetButton').click(function(e){ var parentRow = $(this).closest('tr'); $('input.radio', parentRow).attr('checked', false); }); } }); </script>
The code works very well. But not for array dual scale. Knows everyone how I have to change the code that the reset button works with the array dual scale?To insert a question rest button below and to the right of the array, add this to the source of the question text:
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
addReset('{QID}');
function addQuestionReset(qID) {
$('#question'+qID+' table.subquestions-list').after('<input type="button" style="float:right;" value="Reset Question" class="resetQuestionButton" />');
$('#question'+qID+' .resetQuestionButton').click(function(e){
var parentQuestion = $(this).closest('.array-flexible-row');
$('input.radio', parentQuestion).attr('checked', false);
});
}
});
</script>
Knows everyone how I have to change the code that the reset button works with the array dual scale?
<script type="text/javascript" charset="utf-8"> $(document).ready(function(){ addReset('{QID}'); function addQuestionReset(qID) { var thisQuestion = $('#question'+qID+''); $('table.subquestions-list', thisQuestion).after('<input type="button" style="float:right;" value="Reset Question" class="resetQuestionButton" />'); $('#question'+qID+' .resetQuestionButton').click(function(e){ $('input.radio', thisQuestion).attr('checked', false); }); } }); </script>
Is it possible to set one reset button for two question which are in the same question group?
I have two dual scales side by side and want only one rest button for them.
$('input.radio', thisQuestion).attr('checked', false);
$('.array-flexible-duel-scale input.radio').attr('checked', false);
$('#question775 input.radio, #question1066 input.radio').attr('checked', false);
tpartner wrote: Here is a more generic version of the code:
Code:<script type="text/javascript" charset="utf-8"> $(document).ready(function(){ addReset('{QID}'); function addQuestionReset(qID) { var thisQuestion = $('#question'+qID+''); $('table.subquestions-list', thisQuestion).after('<input type="button" style="float:right;" value="Reset Question" class="resetQuestionButton" />'); $('#question'+qID+' .resetQuestionButton').click(function(e){ $('input.radio', thisQuestion).attr('checked', false); }); } }); </script>
<script type="text/javascript" charset="utf-8"> $(document).ready(function(){ addReset('19'); function addQuestionReset(qID) { var thisQuestion = $('#question'+qID+''); $('table.subquestions-list', thisQuestion).after('<input type="button" style="float:right;" value="Reset Question" class="resetQuestionButton" />'); $('#question'+qID+' .resetQuestionButton').click(function(e){ $('input.radio', thisQuestion).attr('checked', false); }); } }); </script>
<script type="text/javascript" charset="utf-8"> $(document).ready(function(){ addQuestionReset('{QID}'); function addQuestionReset(qID) { var thisQuestion = $('#question'+qID+''); $('table.subquestion-list', thisQuestion).after('<input type="button" style="float:right;" value="Reset Question" class="resetQuestionButton" />'); $('#question'+qID+' .resetQuestionButton').click(function(e){ $('input.radio', thisQuestion).prop('checked', false); }); } }); </script>
tpartner wrote: Try this (no need to modify {QID}):
Code:<script type="text/javascript" charset="utf-8"> $(document).ready(function(){ addQuestionReset('{QID}'); function addQuestionReset(qID) { var thisQuestion = $('#question'+qID+''); $('table.subquestion-list', thisQuestion).after('<input type="button" style="float:right;" value="Reset Question" class="resetQuestionButton" />'); $('#question'+qID+' .resetQuestionButton').click(function(e){ $('input.radio', thisQuestion).prop('checked', false); }); } }); </script>