Welcome, Guest
Username: Password: Remember me

TOPIC: Hidden input values from previous question used to hide current subquestions

Hidden input values from previous question used to hide current subquestions 2 years 10 months ago #67825

  • dmmspac
  • dmmspac's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 2
  • Karma: 0
i wrote the following script to hide subquestions based on the answer values of the previous question. and it works great.
<script type="text/javascript">
$(document).ready(function() {
	var i = 0;
	for (i=0;i<=9;i++) {
		var prevQA = $("#java95735X7X201"+i).val();
		if (prevQA != "0" && prevQA != "1") $("#javatbd95735X7X293"+i).hide();
	}
});
</script>

however, it only works when the previous question's answer values show up as hidden inputs on the current question i'm working with. for example:
<input type='hidden' name='java95735X7X2011' id='java95735X7X2011' value='2' />

for some unknown reason, these hidden input values only show up SOME OF THE TIME for me! i can't figure out why. does anybody have a clue?
The administrator has disabled public write access.

Re: Hidden input values from previous question used to hide current subquestions 2 years 10 months ago #67833

  • dmmspac
  • dmmspac's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 2
  • Karma: 0
mazi from irc chat helped me solve this problem. the hidden input values will only show on a question up when there is a condition placed on showing the question to begin with.

the strange thing is that the condition doesn't have to have anything to do with the previous question. it can be a condition based on some previous question far back in the survey. yet, when you put such a condition in place, the system automatically generates the responses from the previous question in the form of hidden inputs! which of course, you can reference and use to manipulate the present question's subquestions.

strange workaround, but it works!
The administrator has disabled public write access.

Re: Hidden input values from previous question used to hide current subquestions 2 years 10 months ago #67862

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5325
  • Thank you received: 296
  • Karma: 249
Please add your workaround at manual -> workarounds -> Javascrip so other will benefit from your solution as well.

Thanks!

Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)limesurvey.org'"
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.103 seconds
Donation Image