Jump to content

Questionnaire with variable set of questions


clickit

Recommended Posts

I need to create a questionnaire with different set of questions. Suppose I have a lead question with three options:A and B. When user selects option A, questions 4-8 will follow. When user selects option B, questions 9-10 will follow. The rest of the questionnaire remains the same for both options.<DIV><input type radio name=sel value=A onclick="document.set1.style.visibility='visible'"> Option A   <input type=radio name=sel value=B onClick="document.set2.style.visibility='visible'"> Otion B</DIV><DIV name="set1" style="visibility:hidden">Questions 4-8</DIV><DIV name="set2" style="visibility:hidden">Questions 9-10</DIV><DIV> the rest of the questionnaire</DIV> The above codes don't work! Can you help? Is there other alternative methods? Thank you! :)

Link to comment
Share on other sites

Well, you could use javascript functions like this:function setthing(element){if (element=="1"){document.set1.style.visibility="visible"}else{document.set2.style.visibility="visible"}}And then for the form part,<DIV><input type radio name=sel value=A onclick="setthing('1')"> Option A   <input type=radio name=sel value=B onClick="setthing('2')"> Otion B</DIV><DIV name="set1" style="visibility:hidden">Questions 4-8</DIV><DIV name="set2" style="visibility:hidden">Questions 9-10</DIV><DIV> the rest of the questionnaire</DIV>I think that should work.

Link to comment
Share on other sites

Sorry bout that, i meant:

<script type="text/javascript">function setthing(element){if (element=="1"){document.getElementById('set1').style.visibility="visible"document.getElementById('set2').style.visibility="hidden"}else{document.getElementById("set2").style.visibility="visible"document.getElementById("set1").style.visibility="hidden"}}</script>And then for the form part,<form><DIV><input type radio id="sel" value=A onclick="setthing('1')"> Option A   <input type=radio name=sel value=B onClick="setthing('2')"> Otion B</DIV><DIV id="set1" style="visibility:hidden">Questions 4-8</DIV><DIV id="set2" style="visibility:hidden">Questions 9-10</DIV></form><DIV>and so on for the rest of the questionnaire</DIV>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...