Welcome to the LimeSurvey Community Forum

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

Customized table with token and questions

  • CarlottaToletti
  • CarlottaToletti's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
1 year 7 months ago #230997 by CarlottaToletti
Replied by CarlottaToletti on topic Customized table with token and questions
Hi,
I was wondering if it's possible to change the following script to create the same type of question we were talking above but with one difference: the last one column should be a checkbox instead of a menu dropdown (obviously we should have just one option with the checkbox instead of three like in the menu dropdown).

There is the script I'm using now:

<script type="text/javascript" charset="utf-8">
$(document).on('ready pjax:scriptcomplete',function(){
var thisQuestion = $('#question{QID}');

// Insert selects
$('.answer-item.answer_cell_X005', thisQuestion).addClass('with-select').append('<select class="inserted-select form-control list-question-select">\
<option value="">...</option>\
<option value="1">increase</option>\
<option value="2">stay the same</option>\
<option value="3">decrease</option>\
</select>');

// Listeners
$('.inserted-select', thisQuestion).on('change', function(i) {
if($(this).val() != '') {
$(this).closest('.answer-item').find('input:text').val($('option:selected', this).val()).trigger('change');
}
else {
$(this).closest('.answer-item').find('input:text').val('').trigger('change');
}
});

// Returning to page
$('.with-select input:text', thisQuestion).each(function(i) {
var thisCell = $(this).closest('.answer-item');
var inputText = $.trim($(this).val());
$('select.inserted-select', thisCell).val(inputText);
});
// Clean-up styles
$('select.inserted-select', thisQuestion).css({
'max-width': '100%'
});
$('.with-select input:text', thisQuestion).css({
'position': 'absolute',
'left': '-9999em'
});

// Set the first two columns to readonly
$('.answer-item:nth-child(2) input:text', thisQuestion).prop('readonly', true);
$('.answer-item:nth-child(3) input:text', thisQuestion).prop('readonly', true);

});
</script>


Thanks in advance

Carlotta

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 7 months ago #231015 by Joffm
Replied by Joffm on topic Customized table with token and questions
Hi, Carlotta
here you find something to insert checkboxes into your array(text)
[url] forums.limesurvey.org/forum/can-i-do-thi...ith-radiolist#226020 [/url]

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless

Please Log in to join the conversation.

Lime-years ahead

Online-surveys for every purse and purpose