Welcome to the LimeSurvey Community Forum

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

Can I disable some fields within an array (Matrix)

More
9 years 10 months ago - 9 years 10 months ago #108058 by SvenF
Hi,

I have to do an array question but not all questions have the same number of results.

It should look like this for example:
1234
question1XXXX
question2XX
question3XXXX

At question2 there should only 1 and 3 being selectable within the array.

Is this possible or must I do separate questions?
Last edit: 9 years 10 months ago by SvenF.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
9 years 10 months ago - 9 years 10 months ago #108074 by tpartner
Replied by tpartner on topic Can I disable some fields within an array
Assuming you are using a normal array question...

You can use JavaScript/jQuery to hide some of the radio inputs.

Set up your survey to use JavaScript and add a script like below to the question source. This will hide the sixth and eighth radios in the question.

Code:
<script type="text/javascript" charset="utf-8">  
  $(document).ready(function() {
    $('#question{QID} input.radio:eq(5)').hide();
    $('#question{QID} input.radio:eq(7)').hide();
  });
</script>

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 9 years 10 months ago by tpartner.
The topic has been locked.
More
9 years 10 months ago #108104 by SvenF
Replied by SvenF on topic Can I disable some fields within an array
Works fine - thank you
The topic has been locked.
More
3 years 8 months ago #201503 by SvenF
We are now using Lime Survey Pro Hosting. Is it differrent to hide some parts of the matrix? I used the same code as above. JS is running wenn I test with "alert('bla')" but the radios did not hide.
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 8 months ago #201515 by holch
It is the same as with Limesurvey CE. But the solution presented here is most probably not for the version LS 3.x LTS, but probably for LS 2.06 LTS or LS 2.7x, given that this is a 6 year old thread!

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The topic has been locked.
More
3 years 8 months ago #201526 by SvenF
Ok - I know this is my old tread.

We use now LimeSurvey Professional Version 3.22.20. Is ist not possible with this version or can I use another solution?
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 8 months ago #201527 by holch
Should be possible, but needs adaptation, because the HTML of the new templates is different. But I am quite sure that this question has been solved for 3.x lts somewhere in the forum.

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 8 months ago #201529 by tpartner
To follow the example above, try this (untested from memory as I'm responding via phone):

Code:
<script type="text/javascript" charset="utf-8">  
   $(document).ready(function() {
    // Remove row 2, radio 2
    $('#question{QID} tr[id^="javatbd"]:eq(1) .radio-item:eq(1) *').remove();
    // Remove row 2, radio 4
    $('#question{QID} tr[id^="javatbd"]:eq(1) .radio-item:eq(3) *').remove();
  });
</script>

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
More
3 years 8 months ago #201565 by SvenF
That works. Thank you.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose