clickit Posted October 21, 2005 Share Posted October 21, 2005 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 More sharing options...
Chocolate570 Posted October 21, 2005 Share Posted October 21, 2005 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 More sharing options...
clickit Posted October 22, 2005 Author Share Posted October 22, 2005 Chocolate570, thank you for your suggestion! I tried the example given. It returned an error mesage: "document.set1.style" is null or not an object. What is wrong! Can you help? Thank you! Link to comment Share on other sites More sharing options...
Chocolate570 Posted October 22, 2005 Share Posted October 22, 2005 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 More sharing options...
clickit Posted October 22, 2005 Author Share Posted October 22, 2005 Yes, it works! Thank you very much! Chocolate570, Have a nice day! Link to comment Share on other sites More sharing options...
Chocolate570 Posted October 23, 2005 Share Posted October 23, 2005 No problem, good luck with your site. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now