Welcome to the LimeSurvey Community Forum

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

How to hide select options in array with dropdown

  • mikezhangsky
  • mikezhangsky's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
6 years 6 months ago #158970 by mikezhangsky
i want remove the option of select in array question type

q1: which one do you like !


sq1: which one do you like first!

sq2: which one do you like second!

sq3: which one do you like third!

sq4: which one do you like last!


answer with dropdown option

a1-1
a2-2
……

a8-8



i want to hide the option a2 in sq2 , a6 in sq4, i try the js like this,but it dose not work :
Code:
<script charset="utf-8" type="text/javascript">
  $(document).ready(function() {
           $('#answer876992X273X4721x2 option[value=a2]').remove;
 
         }
</script>
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 6 months ago #159013 by tpartner
The element IDs get changed when copying the survey so I would use the element indices instead.

Code:
<script type="text/javascript" charset="utf-8">    
  $(document).ready(function() {  
 
    // Remove: row 2, column 1, option "a2"
    $('#question{QID} .question-item:eq(1) select:eq(0) option[value="a2"]').remove();  
 
    // Remove: row 4, column 1, option "a6"
    $('#question{QID} .question-item:eq(3) select:eq(0) option[value="a6"]').remove();
  });
</script>

Here is your sample survey with that code.

File Attachment:

File Name: limesurvey...6992.lss
File Size:18 KB

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • mikezhangsky
  • mikezhangsky's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
6 years 6 months ago #159273 by mikezhangsky
Replied by mikezhangsky on topic How to hide select options in array with dropdown
thanks . it works .
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose