Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Survey - needing to skip from one quest. to a quest. on another page 2

Status
Not open for further replies.

BettyJo50

Technical User
Apr 25, 2002
47
US
Hi all!!

Here's my situation. I have a survey with 21 questions on 3 pages. Question #8 (on page 1) is a yes or no question (using radio buttons). If you answer "yes" to this question you just continue on to the next question. If you answer "no" to this question, you jump to question #18 (on page 3). I have no idea how to code this to jump to page 3. Can someone PLEASE help me?

Thank you!!
 
There is a relatively easy solution to your problem, but it highly depends on page layout. Are all the questions on the same page? Does a new page load for every question? If the latter is true, it's extremely easy, otherwise there are other workarounds.

-kaht

banghead.gif
 
No, there are 3 pages. Questions 1-8 are on page 1 (survey.php), questions 9-17 are on page 2 (survey2.php) and questions 18-21 are on page 3 (survey3.php). If you answer yes to question 8 they just move on to the next question, if they answer no to question 8, they need to be sent to question 18 which is on page 3.

Does that make sense?

Thanks!
 
document.location='anotherpage.html';
 
If you are submitting the page after each user answers a set of questions, then you can use the onsubmit to check where it's going. Here's a few small snippets of code, just work them into what you've got.
Code:
<script language=javascript>
function checkNext() {
   if (blahForm.question8[0].checked) {
      blahForm.action = 'page2.html';
   }
   else {
      blahForm.action = 'page3.html';
   }
   return true;
}
</script>
<form name=blahForm onsubmit='checkNext()' action='page2.html'>
<input type=submit name=blahSubmit value='More Questions'>
<input type=radio name=question8>Yes
<input type=radio name=question8>No

-kaht

banghead.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top