- Posts: 28
- Thank you received: 0
Ask the community, share ideas, and connect with other LimeSurvey users!
to hide some cells of the array B
the question Q001 of the array B must be hide
.if question Q001 of the array A is not answered
<div class="hidden equation"> {implode(',', if(D1_D1Y1_D1X1 == '1', 'D1Y1_D1X1', ''), if(D1_D1Y1_D1X2 == '1', 'D1Y1_D1X2', ''), if(D1_D1Y1_D1X3 == '1', 'D1Y1_D1X3', ''), if(D1_D1Y2_D1X1 == '1', 'D1Y2_D1X1', ''), if(D1_D1Y2_D1X2 == '1', 'D1Y2_D1X2', ''), if(D1_D1Y2_D1X3 == '1', 'D1Y2_D1X3', ''), if(D1_D1Y3_D1X1 == '1', 'D1Y3_D1X1', ''), if(D1_D1Y3_D1X2 == '1', 'D1Y3_D1X2', ''), if(D1_D1Y3_D1X3 == '1', 'D1Y3_D1X3', ''), if(D1_D1Y4_D1X1 == '1', 'D1Y4_D1X1', ''), if(D1_D1Y4_D1X2 == '1', 'D1Y4_D1X2', ''), if(D1_D1Y4_D1X3 == '1', 'D1Y4_D1X3', ''))} </div>
<script type="text/javascript" charset="utf-8"> $(document).on('ready pjax:scriptcomplete',function(){ var q1Code = 'D1'; var q2Code = 'D2'; var answeredQ1 = $.trim($('#question{QID} .hidden.equation:eq(0)').text()).split(','); // Loop through answers from Q1 and add classes to the corresponding Q2 inputs $.each(answeredQ1, function(i, val) { var re = new RegExp(q1Code, 'g'); var q2CellCode = val.replace(re, q2Code); if(val != '') { $('#question{QID} input[type="text"][id$="'+q2CellCode+'"]').addClass('relevant'); } }); // Disable irrelevant items $('#question{QID} input[type="text"]:not(.relevant)').prop('disabled', true).val(''); }); </script>