Check out the LimeSurvey source code on GitHub!
Welcome, Guest
Username: Password:

TOPIC: Script to hide answers

Script to hide answers 5 years 11 months ago #53943

  • jkveenstra
  • jkveenstra's Avatar
  • Offline
  • Fresh Lemon
  • Posts: 5
  • Karma: 1
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)
The administrator has disabled public write access.

Script to hide answers 5 years 11 months ago #53946

  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 5425
  • Thank you received: 807
  • Karma: 239
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.
Have a look at the manual! It is a really valuable source for information. Here some helpful links:
Manual (EN) | Question Types | [url=https://manual.limesurvey.org/Workarounds[/url]

If you found this answer helpful and it saved you some time please consider a [url=https://donate.limesurvey.org[/url] to the...
The administrator has disabled public write access.

Script to hide answers 5 years 11 months ago #53952

  • Mazi
  • Mazi's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 6028
  • Thank you received: 373
  • Karma: 260
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'"
The administrator has disabled public write access.

Script to hide answers 5 years 11 months ago #53964

  • jkveenstra
  • jkveenstra's Avatar
  • Offline
  • Fresh Lemon
  • Posts: 5
  • Karma: 1
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.
The administrator has disabled public write access.

Script to hide answers 5 years 11 months ago #53969

  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 5425
  • Thank you received: 807
  • Karma: 239
Well, 1.73 sounds like really, really old. There have been some great improvements to Limesurvey since then.
Have a look at the manual! It is a really valuable source for information. Here some helpful links:
Manual (EN) | Question Types | [url=https://manual.limesurvey.org/Workarounds[/url]

If you found this answer helpful and it saved you some time please consider a [url=https://donate.limesurvey.org[/url] to the...
The administrator has disabled public write access.

Script to hide answers 5 years 11 months ago #53976

  • jkveenstra
  • jkveenstra's Avatar
  • Offline
  • Fresh Lemon
  • Posts: 5
  • Karma: 1
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.
The administrator has disabled public write access.

Script to hide answers 5 years 11 months ago #54006

  • Mazi
  • Mazi's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 6028
  • Thank you received: 373
  • Karma: 260
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'"
The administrator has disabled public write access.

Script to hide answers 5 years 11 months ago #54010

  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 5425
  • Thank you received: 807
  • Karma: 239
@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.
Have a look at the manual! It is a really valuable source for information. Here some helpful links:
Manual (EN) | Question Types | [url=https://manual.limesurvey.org/Workarounds[/url]

If you found this answer helpful and it saved you some time please consider a [url=https://donate.limesurvey.org[/url] to the...
The administrator has disabled public write access.
Time to create page: 0.286 seconds
Imprint                   Privacy policy         General Terms & Conditions         Revocation information and revocation form