- Posts: 57
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Can I combine List(radio) and List (dropdown) into one question?
- xueting
- Topic Author
- Offline
- Senior Member
Less
More
2 years 2 months ago #225503
by xueting
Can I combine List(radio) and List (dropdown) into one question? was created by xueting
Please help us help you and fill where relevant:Your LimeSurvey version: [3.28.0]Own server or LimeSurvey hosting: TU/eSurvey theme/template: Can I combine List(radio) and List (dropdown) into one question?==================
Hi all,
In the following situation, if 'others' in the List(radio) question is selected, then the next List (dropdown) question would show.
But I suppose seems a more efficient way is to insert dropdown into the 'others' option of List(radio) like the following photoshopped picture shows.
I was wondering is it possible? Thank you for your attention.
Regards,
Xueting
Hi all,
In the following situation, if 'others' in the List(radio) question is selected, then the next List (dropdown) question would show.
But I suppose seems a more efficient way is to insert dropdown into the 'others' option of List(radio) like the following photoshopped picture shows.
I was wondering is it possible? Thank you for your attention.
Regards,
Xueting
Please Log in to join the conversation.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10109
- Thank you received: 3593
2 years 2 months ago #225514
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 Can I combine List(radio) and List (dropdown) into one question?
You can use JavaScript to move the drop-down from the following question into the last option of the list-radio.
Something like this in the source of the list-radio:
Sample survey attached:
Something like this in the source of the list-radio:
Code:
<script type="text/javascript" data-author="Tony Partner"> $(document).on('ready pjax:scriptcomplete',function(){ // The text for the "Please choose" option var chooseText = { 'en': 'Please choose...', 'de': 'Bitte auswählen...', 'fr': ' Veuillez choisir ...' } // Identify this question var qID = '{QID}'; var thisQuestion = $('#question'+qID); var nextQuestion = $(thisQuestion).nextAll('.list-dropdown:eq(0)'); var lang = $('html').attr('lang'); // Hide the next question nextQuestion.hide(); // Move the dropdown $('.answer-item.radio-item:last', thisQuestion).append($('.answer-item', nextQuestion)); // Cleanup styles $('.answer-item.radio-item .answer-item', thisQuestion).css({ 'display': 'inline-block', 'margin-left': '1em', 'padding': '0' }); function handleOther() { if($('.answer-item.radio-item:last :radio:checked', thisQuestion).length == 0) { $('.answer-item.radio-item .answer-item', thisQuestion).hide(); $('.answer-item.radio-item .answer-item input[type="hidden"]', thisQuestion).val(''); $('.answer-item.radio-item .answer-item select', thisQuestion).val('').trigger('change'); } else { $('.answer-item.radio-item .answer-item', thisQuestion).show(); } } // Initial state handleOther(); var iChooseText = chooseText['en']; if(lang in chooseText) { iChooseText = chooseText[lang]; } if($('select.form-control option[value=""]', thisQuestion).length == 0) { $('select.form-control', thisQuestion).prepend('<option value="">'+iChooseText+'</option>'); } // Listener on the radios $('.answer-item.radio-item :radio', thisQuestion).on('click', function(e) { handleOther(); }); }); </script>
Sample survey attached:
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: xueting
Please Log in to join the conversation.
- xueting
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 57
- Thank you received: 0
2 years 1 month ago #225636
by xueting
Replied by xueting on topic Can I combine List(radio) and List (dropdown) into one question?
Thank you Tony Partner for your solution. It's amazing to see the idea come true!
Regards,
Xueting
Regards,
Xueting
Please Log in to join the conversation.