- Posts: 125
- Thank you received: 4
- Forum
- English support forums
- Can I do this with LimeSurvey?
- Last Option In Array (Numbers) (Checkboxes) column Excludes All Others
Last Option In Array (Numbers) (Checkboxes) column Excludes All Others
1 year 6 months ago #208762
by surveySn
Hello everyone,
Last Option In Array (Numbers) (Checkboxes) column Excludes All Others
manual.limesurvey.org/Workarounds:_Manip..._Excludes_All_Others
How do it?
I searched the forum and there was no answer to the column.
Last Option In Array (Numbers) (Checkboxes) column Excludes All Others
manual.limesurvey.org/Workarounds:_Manip..._Excludes_All_Others
How do it?
I searched the forum and there was no answer to the column.
The topic has been locked.
1 year 6 months ago - 1 year 6 months ago #208764
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Last Option In Array (Numbers) (Checkboxes) column Excludes All Others
Do not double-post.
- forums.limesurvey.org/forum/can-i-do-thi...-all-others&start=15I searched the forum and there was no answer to the column.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 1 year 6 months ago by tpartner.
The topic has been locked.
1 year 6 months ago #208766
by surveySn
Replied by surveySn on topic Last Option In Array (Numbers) (Checkboxes) column Excludes All Others
forums.limesurvey.org/forum/can-i-do-thi...-all-others&start=15
This is row exclusive,
I want to be column exclusive,
could you help me,
Version 3.22.11 + 200330
This is row exclusive,
I want to be column exclusive,
could you help me,
Version 3.22.11 + 200330
The topic has been locked.
1 year 6 months ago #208767
by surveySn
Replied by surveySn on topic Last Option In Array (Numbers) (Checkboxes) column Excludes All Others
Sorry, I changed my reply,
The topic has been locked.
1 year 6 months ago #208769
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Last Option In Array (Numbers) (Checkboxes) column Excludes All Others
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Attachments:
The topic has been locked.
1 year 6 months ago #208771
by surveySn
Replied by surveySn on topic Last Option In Array (Numbers) (Checkboxes) column Excludes All Others
Attachments:
The topic has been locked.
1 year 6 months ago #208789
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Last Option In Array (Numbers) (Checkboxes) column Excludes All Others
Oh, an exclusive row...
Can you attach a small sample survey (.lss file) containing only that question?
Can you attach a small sample survey (.lss file) containing only that question?
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
1 year 6 months ago #208796
by surveySn
Replied by surveySn on topic Last Option In Array (Numbers) (Checkboxes) column Excludes All Others
SQ007_A and SQ007_B and SQ007_C and SQ007_D and SQ007_E and SQ007_F and SQ007_G It's exclusive
Attachments:
The topic has been locked.
1 year 6 months ago - 1 year 6 months ago #208815
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Last Option In Array (Numbers) (Checkboxes) column Excludes All Others
So, to be clear...
Every row is exclusive (only one answer per column) or the last row is exclusive (last row excludes all other answers in the same column)?
Every row is exclusive (only one answer per column) or the last row is exclusive (last row excludes all other answers in the same column)?
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 1 year 6 months ago by tpartner.
The topic has been locked.
1 year 6 months ago #208823
by surveySn
Replied by surveySn on topic Last Option In Array (Numbers) (Checkboxes) column Excludes All Others
the last row is exclusive (last row excludes all other answers in the same column)
My English is poor and I don't express myself clearly,
My English is poor and I don't express myself clearly,

The topic has been locked.
1 year 6 months ago #208844
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Last Option In Array (Numbers) (Checkboxes) column Excludes All Others
Add this script to the source of the question:
Here is a sample survey:
<script type="text/javascript" charset="utf-8">
$(document).on('ready pjax:scriptcomplete',function(){
// Identify this question
var qID = '{QID}';
var thisQuestion = $('#question'+qID);
// Assign column-specific attributes and classnames
$('tr.subquestion-list', thisQuestion).each(function(i) {
$('> *', this).each(function(i) {
$(this).attr('data-column', i);
});
});
$('tr.subquestion-list:last td.answer-item', thisQuestion).addClass('exclusive-item');
// A function to un-check boxes
function resetCheckbox(thisItem) {
$(':hidden', thisItem).val('');
$(':checkbox', thisItem).prop('checked', false).trigger('change');
}
// Listener on the checkboxes
$(':checkbox', thisQuestion).on('change', function(e) {
if($(this).is(':checked')) {
var thisItem = $(this).closest('.answer-item');
var thisColumn = $(thisItem).attr('data-column');
var items = $('td.answer-item[data-column="'+thisColumn+'"].exclusive-item', thisQuestion);
if($(thisItem).hasClass('exclusive-item')) {
items = $('td.answer-item[data-column="'+thisColumn+'"]:not(.exclusive-item)', thisQuestion);
}
$.each(items, function(i, el) {
resetCheckbox(el);
});
}
});
});
</script>
Here is a sample survey:
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Attachments:
The topic has been locked.
1 year 6 months ago #208856
by surveySn
Replied by surveySn on topic Last Option In Array (Numbers) (Checkboxes) column Excludes All Others
Great Tony,
thank you,
I have another question,
I play random sub problems,
fixed the last item,
Use your script,
Not the last row excludes
thank you,
I have another question,
I play random sub problems,
fixed the last item,
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
// The subquestion code to place in the last position
var fixedCode = 'A20';
// Identify this question
var q1ID = {QID};
var thisQuestion = $('#question'+q1ID);
// Move the "fixed" row to the end
$('table.subquestion-list tbody:last', thisQuestion).append($('tr[id$="X'+q1ID+fixedCode+'"]'));
// Fix up the array row background colours
$('tr.answers-list', thisQuestion).each(function(i){
$(this).removeClass('array1 array2').addClass('array'+(2-(i%2)));
});
});
</script>
Use your script,
<script type="text/javascript" charset="utf-8">
$(document).on('ready pjax:scriptcomplete',function(){
// Identify this question
var qID = '{QID}';
var thisQuestion = $('#question'+qID);
// Assign column-specific attributes and classnames
$('tr.subquestion-list', thisQuestion).each(function(i) {
$('> *', this).each(function(i) {
$(this).attr('data-column', i);
});
});
$('tr.subquestion-list:last td.answer-item', thisQuestion).addClass('exclusive-item');
// A function to un-check boxes
function resetCheckbox(thisItem) {
$(':hidden', thisItem).val('');
$(':checkbox', thisItem).prop('checked', false).trigger('change');
}
// Listener on the checkboxes
$(':checkbox', thisQuestion).on('change', function(e) {
if($(this).is(':checked')) {
var thisItem = $(this).closest('.answer-item');
var thisColumn = $(thisItem).attr('data-column');
var items = $('td.answer-item[data-column="'+thisColumn+'"].exclusive-item', thisQuestion);
if($(thisItem).hasClass('exclusive-item')) {
items = $('td.answer-item[data-column="'+thisColumn+'"]:not(.exclusive-item)', thisQuestion);
}
$.each(items, function(i, el) {
resetCheckbox(el);
});
}
});
});
</script>
Not the last row excludes
Attachments:
The topic has been locked.
1 year 6 months ago - 1 year 6 months ago #208865
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Last Option In Array (Numbers) (Checkboxes) column Excludes All Others
Apply the exclusive script before the fixed-row script.
<script type="text/javascript" charset="utf-8">
$(document).on('ready pjax:scriptcomplete',function(){
// Identify this question
var qID = '{QID}';
var thisQuestion = $('#question'+qID);
// Assign column-specific attributes and classnames
$('tr.subquestion-list', thisQuestion).each(function(i) {
$('> *', this).each(function(i) {
$(this).attr('data-column', i);
});
});
$('tr.subquestion-list:last td.answer-item', thisQuestion).addClass('exclusive-item');
// A function to un-check boxes
function resetCheckbox(thisItem) {
$(':hidden', thisItem).val('');
$(':checkbox', thisItem).prop('checked', false).trigger('change');
}
// Listener on the checkboxes
$(':checkbox', thisQuestion).on('change', function(e) {
if($(this).is(':checked')) {
var thisItem = $(this).closest('.answer-item');
var thisColumn = $(thisItem).attr('data-column');
var items = $('td.answer-item[data-column="'+thisColumn+'"].exclusive-item', thisQuestion);
if($(thisItem).hasClass('exclusive-item')) {
items = $('td.answer-item[data-column="'+thisColumn+'"]:not(.exclusive-item)', thisQuestion);
}
$.each(items, function(i, el) {
resetCheckbox(el);
});
}
});
// The subquestion code to place in the last position
var fixedCode = 'A20';
// Move the "fixed" row to the end
$('table.subquestion-list tbody:last', thisQuestion).append($('tr[id$="X'+qID+fixedCode+'"]'));
// Fix up the array row background colours
$('tr.answers-list', thisQuestion).each(function(i){
$(this).removeClass('array1 array2').addClass('array'+(2-(i%2)));
});
});
</script>
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 1 year 6 months ago by tpartner.
The topic has been locked.
1 year 6 months ago #208868
by surveySn
Replied by surveySn on topic Last Option In Array (Numbers) (Checkboxes) column Excludes All Others
Hi Tony
If random order is used
Can't fixed the last row,
If random order is used
Can't fixed the last row,
Attachments:
The topic has been locked.
1 year 6 months ago #208891
by tpartner
Sample survey attached:
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Last Option In Array (Numbers) (Checkboxes) column Excludes All Others
<script type="text/javascript" charset="utf-8">
$(document).on('ready pjax:scriptcomplete',function(){
// Identify this question
var qID = '{QID}';
var thisQuestion = $('#question'+qID);
// Assign column-specific attributes and classnames
$('tr.subquestion-list', thisQuestion).each(function(i) {
$('> *', this).each(function(i) {
$(this).attr('data-column', i);
});
});
$('tr.subquestion-list:last td.answer-item', thisQuestion).addClass('exclusive-item');
// A function to un-check boxes
function resetCheckbox(thisItem) {
$(':hidden', thisItem).val('');
$(':checkbox', thisItem).prop('checked', false).trigger('change');
}
// Listener on the checkboxes
$(':checkbox', thisQuestion).on('change', function(e) {
if($(this).is(':checked')) {
var thisItem = $(this).closest('.answer-item');
var thisColumn = $(thisItem).attr('data-column');
var items = $('td.answer-item[data-column="'+thisColumn+'"].exclusive-item', thisQuestion);
if($(thisItem).hasClass('exclusive-item')) {
items = $('td.answer-item[data-column="'+thisColumn+'"]:not(.exclusive-item)', thisQuestion);
}
$.each(items, function(i, el) {
resetCheckbox(el);
});
}
});
// The subquestion code to place in the last position
var fixedCode = 'A20';
// Move the "fixed" row to the end
$('table.subquestion-list tbody:last', thisQuestion).append($('tr[id$="X'+qID+fixedCode+'"]'));
// Fix up the array row background colours
$('tr.answers-list', thisQuestion).each(function(i){
$(this).removeClass('array1 array2').addClass('array'+(2-(i%2)));
});
});
</script>
Sample survey attached:
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Attachments:
The topic has been locked.