- Posts: 57
- Thank you received: 0
Ask the community, share ideas, and connect with other LimeSurvey users!
Please Log in to join the conversation.
<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>
Please Log in to join the conversation.
Please Log in to join the conversation.