Check out the LimeSurvey source code on GitHub!

Script to hide answers

More
6 years 2 months ago #53943 by jkveenstra
I found a script to hide the answers of a question (dependent on a previous question, which is a list with checkboxes).
<script type="text/javascript">
 
function Custom_On_Load(){
 
if ( '{INSERTANS:37115X90X2668SQ001}' = 'Y' ) {
$('#javatbd37115X91X2683SQ001').show();
}
else {
$('#javatbdS37115X91X2683SQ001').hide();
$('#javatbd37115X91X2683SQ001 input').each(function(i) {
$(this).attr('checked', false);
});
}
 
 
// 	And repeat as necessary
}
</script>

Unfortunately I don't get it to work. I tried the following:
    Set the XSS-Filter to "false"
    Copied the script into the question (under "code" in the wysiwyg)

Please Log in to join the conversation.

More
6 years 2 months ago #53946 by holch
Did you change the codes for the questions according to your question codes? (e.g. 37115X90X2668SQ001)?

I don't know if you knew it, but in many cases you can use the array filter option to hide answers depending on previous questions.

I'm not a LimeSurvey GmbH member. I answer at the LimeSurvey forum in my spare time. No support via private message.
Some helpful links: Manual (EN) | Question Types | Workarounds

Please Log in to join the conversation.

More
6 years 2 months ago #53952 by Mazi
1. Which Limesurvey version do you use?

2. Where did you find this code snippet?

3. Any error messages? "Doesn't work" isn't very helpful.

4. Please switch on debug mode by adding the following line to your config.php file:
$debug = '1';

Are there any additional errors reported on top of the page?


Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)survey-consulting.com'"

Please Log in to join the conversation.

More
6 years 2 months ago #53964 by jkveenstra
Thank you for pointing me to this solution! This works great.

I've been working with version 1.73 (and upgraded lately) and was not familiar with this function yet.

Keep up the good work!

PS. I did donate some time a go.

Please Log in to join the conversation.

More
6 years 2 months ago #53969 by holch
Well, 1.73 sounds like really, really old. There have been some great improvements to Limesurvey since then.

I'm not a LimeSurvey GmbH member. I answer at the LimeSurvey forum in my spare time. No support via private message.
Some helpful links: Manual (EN) | Question Types | Workarounds

Please Log in to join the conversation.

More
6 years 2 months ago #53976 by jkveenstra
Dear Mazi,

Thank you for your response.

1. Which Limesurvey version do you use?

2. Where did you find this code snippet?

3. Any error messages? "Doesn't work" isn't very helpful.

4. Please switch on debug mode by adding the following line to your config.php file:
Code:
$debug = '1';


Are there any additional errors reported on top of the page?


1. Versie 1.90+ Build 9229
2. On the forum: www.limesurvey.org/en/support/forums/2-d...ding-on-other-matrix
3. No error message at all.
4. Thanks for the tip: I'll use it in future before posting on the forum.
5. no additional errors.

Fortunately "Holch" pointed me in the right direction.

Thanks for all the quick replies.

Please Log in to join the conversation.

More
6 years 2 months ago #54006 by Mazi
Yep, mind the IDs, they have to fit!


Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)survey-consulting.com'"

Please Log in to join the conversation.

More
6 years 2 months ago #54010 by holch
@Mazi: I think I didn't solve the actual problem (Javascript solution not working), but pointed jkveenstra to the array filter, which in this case seems to do the job.

I'm not a LimeSurvey GmbH member. I answer at the LimeSurvey forum in my spare time. No support via private message.
Some helpful links: Manual (EN) | Question Types | Workarounds

Please Log in to join the conversation.

Imprint                   Privacy policy         General Terms & Conditions         Revocation information and revocation form