- Posts: 54
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
array filter in sub answer
- nibos
- Topic Author
- Offline
- Senior Member
Less
More
8 years 5 months ago #127570
by nibos
array filter in sub answer was created by nibos
Attachments:
The topic has been locked.
- holch
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11639
- Thank you received: 2737
8 years 5 months ago #127574
by holch
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
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.
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
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10099
- Thank you received: 3589
8 years 5 months ago - 8 years 5 months ago #127592
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
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: 8 years 5 months ago by tpartner.
The topic has been locked.
- nibos
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 54
- Thank you received: 0
8 years 5 months ago #127596
by nibos
Replied by nibos on topic array filter in sub answer
Attachments:
The topic has been locked.
- holch
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11639
- Thank you received: 2737
8 years 5 months ago #127607
by holch
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
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?
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.
- holch
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11639
- Thank you received: 2737
8 years 5 months ago - 8 years 5 months ago #127640
by holch
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
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:
And here how it looks like:
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:
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Attachments:
Last edit: 8 years 5 months ago by holch.
The topic has been locked.
- holch
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11639
- Thank you received: 2737
8 years 5 months ago #127642
by holch
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
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.
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?
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?
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Attachments:
The following user(s) said Thank You: delarammahdaviii
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10099
- Thank you received: 3589
8 years 5 months ago #127650
by tpartner
with:
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic array filter in sub answer
Ah, good point - replace all instances of :While the radio buttons don't show, it seems that they can still be clicked.
Code:
.hide()
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.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10099
- Thank you received: 3589
8 years 5 months ago #127652
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
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.
- delarammahdaviii
- Offline
- Senior Member
Less
More
- Posts: 57
- Thank you received: 3
8 years 2 months ago - 8 years 2 months ago #131047
by delarammahdaviii
Replied by delarammahdaviii on topic array filter in sub answer
hi
what's code for array ( number ) ?
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: 8 years 2 months ago by delarammahdaviii.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10099
- Thank you received: 3589
8 years 2 months ago #131049
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
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.
- delarammahdaviii
- Offline
- Senior Member
Less
More
- Posts: 57
- Thank you received: 3
8 years 2 months ago #131051
by delarammahdaviii
Replied by delarammahdaviii on topic array filter in sub answer
thanks for help
i want do this
i want do this
Attachments:
The topic has been locked.