Welcome to the LimeSurvey Community Forum

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

array filter in sub answer

More
9 years 10 months ago #127570 by nibos
Can I hide an array answers as in the attached image?
The topic has been locked.
More
9 years 10 months ago #127574 by holch
Replied by holch on topic array filter in sub answer
This is not a question about the development of the limesurvey software, but rather of what you can do with Limesurvey. I'll move it to the correct forum.

Help us to help you!
  • Provide your LS version and where it is installed (own server, uni/employer, SaaS hosting, etc.).
  • Always provide a LSS file (not LSQ or LSG).
Note: I answer at this forum in my spare time, I'm not a LimeSurvey GmbH employee.
The topic has been locked.
More
9 years 10 months ago - 9 years 10 months ago #127592 by tpartner
Replied by tpartner on topic array filter in sub answer
Set up your survey to use JavaScript and add something like this to the question source:

Code:
<script type="text/javascript" charset="utf-8">    
  $(document).ready(function(){
    //Hide the last radio in the first row
    $('#question'+{QID}+' tr.answers-list:first input.radio:last').remove();
  });
</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 #127596 by nibos
Replied by nibos on topic array filter in sub answer
Tpartner,

Thank you very much for that. It worked.

I want to do almost the same with Multiple choice with comments (see attached). Is it feasible? Your help is very important.



Thank you in advance.
The topic has been locked.
More
9 years 10 months ago #127607 by holch
Replied by holch on topic array filter in sub answer
Hi Tpartner, this works great. However, is there a way to subsitute "first" and "last" with a specific answer option? Just to add more flexibility. Because if the array is randomized, "first" and "last" might not work, or if I would actually hide the middle button for a specific question. Is there a way to make this script more flexible?

Help us to help you!
  • Provide your LS version and where it is installed (own server, uni/employer, SaaS hosting, etc.).
  • Always provide a LSS file (not LSQ or LSG).
Note: I answer at this forum in my spare time, I'm not a LimeSurvey GmbH employee.
The topic has been locked.
More
9 years 10 months ago - 9 years 10 months ago #127640 by holch
Replied by holch on topic array filter in sub answer
hehehehe, sometimes it is good when Tpartner isn't responding quickly. I had a little break and used it to learn a little bit. Searched for "javascript :last" and found a page about potential selectors here: www.w3schools.com/jquery/jquery_ref_selectors.asp

So I played around a little and found :eq(x) as a selector. This wouldn't work if the question is randomized, so I am still looking for this, but at least this is more flexible than first and last as selectors.

So in addition to the last radio button of the first line, I also hid the 3rd button of the 3rd line:
Code:
<script type="text/javascript" charset="utf-8">    
  $(document).ready(function(){
    //Hide the last radio in the first row
    $('#question'+{QID}+' tr.answers-list:first input.radio:last').hide();
                $('#question'+{QID}+' tr.answers-list:eq(2) input.radio:eq(2)').hide();
  });
</script>

And here how it looks like:


Help us to help you!
  • Provide your LS version and where it is installed (own server, uni/employer, SaaS hosting, etc.).
  • Always provide a LSS file (not LSQ or LSG).
Note: I answer at this forum in my spare time, I'm not a LimeSurvey GmbH employee.
Last edit: 9 years 10 months ago by holch.
The topic has been locked.
More
9 years 10 months ago #127642 by holch
Replied by holch on topic array filter in sub answer
OK, so with a little playing around I finally found a good solution that is also "randomization" save, or at least should be from my understanding.
Code:
<script type="text/javascript" charset="utf-8">    
  $(document).ready(function(){
    //Hide the last radio in the first row
    $('#question'+{QID}+' tr.answers-list:first input.radio:last').hide();
                //Hide the 3rd radio in the 3rd row
                $('#question'+{QID}+' tr.answers-list:eq(2) input.radio:eq(2)').hide();
                //Hide the first radio of Option 4
                $('#answer433587X129X10164-1').hide();
  });
</script>



This should work with the comment boxes as well. Will give it a try later. But there is one flaw to this method. While the radio buttons don't show, it seems that they can still be clicked. Is there any way to avoid this?

Help us to help you!
  • Provide your LS version and where it is installed (own server, uni/employer, SaaS hosting, etc.).
  • Always provide a LSS file (not LSQ or LSG).
Note: I answer at this forum in my spare time, I'm not a LimeSurvey GmbH employee.
The following user(s) said Thank You: delarammahdaviii
The topic has been locked.
More
9 years 10 months ago #127650 by tpartner
Replied by tpartner on topic array filter in sub answer

While the radio buttons don't show, it seems that they can still be clicked.

Ah, good point - replace all instances of :
Code:
.hide()
with:
Code:
.remove()

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: holch
The topic has been locked.
More
9 years 10 months ago #127652 by tpartner
Replied by tpartner on topic array filter in sub answer
This will remove the comment field from the first row of a multiple-choice-with-comments question. As Holch suggests, if you want to randomize, you will need to use a more specific selector.

Code:
<script type="text/javascript" charset="utf-8">    
  $(document).ready(function(){
    $('#question{QID} li.question-item:eq(0) span.comment').hide();
  });
</script>

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: delarammahdaviii
The topic has been locked.
More
9 years 6 months ago - 9 years 6 months ago #131047 by delarammahdaviii
hi
what's code for array ( number ) ?

boriginal wrote:

Code:
<script type="text/javascript" charset="utf-8">    
  $(document).ready(function(){
 
                //Hide what ever you want by adding the code of your interactive element
                $('#cbox_585145X141X34956_1').hide();
  });
</script>

Last edit: 9 years 6 months ago by delarammahdaviii.
The topic has been locked.
More
9 years 6 months ago #131049 by tpartner
Replied by tpartner on topic array filter in sub answer
Please explain exactly what you are trying to do.

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
9 years 6 months ago #131051 by delarammahdaviii
thanks for help
i want do this
The topic has been locked.
More
9 years 6 months ago #131062 by delarammahdaviii
can i use Subquestion Relevance for this cell : Qcode_6_d= 0
or some things like this ?
The topic has been locked.
More
9 years 6 months ago #131075 by holch
Replied by holch on topic array filter in sub answer
As far as I know, subquestion relevance will show/hide the whole subquestion depending on the relevance equation written in the field.

So the relevance equation 'Qcode_6_d" would mean that the subquestion (the whole line) should not be shown when that specific field is zero. Which doesn't make sense.

Help us to help you!
  • Provide your LS version and where it is installed (own server, uni/employer, SaaS hosting, etc.).
  • Always provide a LSS file (not LSQ or LSG).
Note: I answer at this forum in my spare time, I'm not a LimeSurvey GmbH employee.
The topic has been locked.
More
9 years 6 months ago #131103 by delarammahdaviii
so, what can i do ?
i thing most use JS code .
The topic has been locked.
Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose