Check out the LimeSurvey source code on GitHub!

Hidden input values from previous question used to hide current subquestions

More
5 years 4 months ago #67825 by dmmspac
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?

Please Log in to join the conversation.

More
5 years 4 months ago #67833 by dmmspac
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!

Please Log in to join the conversation.

More
5 years 3 months ago #67862 by Mazi
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)survey-consulting.com'"

Please Log in to join the conversation.

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