- Posts: 10
- Thank you received: 0
Ask the community, share ideas, and connect with other LimeSurvey users!
Hi tpartner, thank you for the answer, can we do this using javascript?
<script type="text/javascript" charset="utf-8"> $(document).on('ready pjax:scriptcomplete',function(){ // Define the previous answer(s) var q1Value = '{Q1}'; // Identify the drop-down var thisSelect = $('#question{QID} select.form-control:eq(0)'); // Reset the drop-down if its value equals previous answer(s) if(thisSelect.val() == q1Value) { if($('option[value=""]', thisSelect).length == 0) { $(thisSelect).prepend('<option value="">Please choose...</option>'); } thisSelect.val(''); } // Remove drop-down option $('option[value="'+q1Value+'"]', thisSelect).remove(); }); </script>
<script type="text/javascript" charset="utf-8"> $(document).on('ready pjax:scriptcomplete',function(){ // Define the previous answer(s) var q1Value = '{Q1}'; var q2Value = '{Q2}'; // Identify the drop-down var thisSelect = $('#question{QID} select.form-control:eq(0)'); // Reset the drop-down if its value equals previous answer(s) if(thisSelect.val() == q1Value || thisSelect.val() == q2Value) { if($('option[value=""]', thisSelect).length == 0) { $(thisSelect).prepend('<option value="">Please choose...</option>'); } thisSelect.val(''); } // Remove drop-down options $('option[value="'+q1Value+'"]', thisSelect).remove(); $('option[value="'+q2Value+'"]', thisSelect).remove(); }); </script>