Forums
This topic is locked
ASP Newbe / forums
Posted 06 Feb 2006 01:10:10
1
has voted
06 Feb 2006 01:10:10 Jack Black posted:
Hi Guys, I have been playing around with dreamweavers form's feature and now need some code/programming help. What I have is a question that allows the user to select from 4 different answers that have radio buttons next to the answers. Now A is the correct answer, and if they click on the option A radio button and then hit submit, or continue I want a page redirect to happen. Where as if they click on any of the other radio button and hit submit I want them redirected to a different page...
Can anyone give me some help?
Replies
Replied 06 Feb 2006 22:06:09
06 Feb 2006 22:06:09 Russell Biscardine replied:
OK, not sure if this is what you want, but here goes...
<pre id=code><font face=courier size=2 id=code>
Dim Question, Answer
Question = "What is the capital of France?"
Answer = "2"
If Request.Form <> "" Then
If Request.Form("Questions" = Answer Then
Response.Redirect("Correct.asp"
Else
Response.Redirect("Incorrect.asp"
End If
End If
</font id=code></pre id=code>
Here is the HTML part
<pre id=code><font face=courier size=2 id=code>
<form action="" method="post" name="QNA">
<P><%=Question%></P>
<p>
<label>
<input type="radio" name="Questions" value="1">
London</label>
<br>
<label>
<input type="radio" name="Questions" value="2">
Paris</label>
<br>
<label>
<input type="radio" name="Questions" value="3">
Hamburg</label>
<br>
<label>
<input type="radio" name="Questions" value="4">
Barcelona</label>
<br>
</p>
<input name="Check" type="submit" value="Check">
</form>
</font id=code></pre id=code>
<a href="www.code-z.co.uk" title="Code-Z :: Digital Media & Content Creation"><img src="www.code-z.co.uk/media/AffiliateLogo.jpg" border="0"></a>
<pre id=code><font face=courier size=2 id=code>
Dim Question, Answer
Question = "What is the capital of France?"
Answer = "2"
If Request.Form <> "" Then
If Request.Form("Questions" = Answer Then
Response.Redirect("Correct.asp"
Else
Response.Redirect("Incorrect.asp"
End If
End If
</font id=code></pre id=code>
Here is the HTML part
<pre id=code><font face=courier size=2 id=code>
<form action="" method="post" name="QNA">
<P><%=Question%></P>
<p>
<label>
<input type="radio" name="Questions" value="1">
London</label>
<br>
<label>
<input type="radio" name="Questions" value="2">
Paris</label>
<br>
<label>
<input type="radio" name="Questions" value="3">
Hamburg</label>
<br>
<label>
<input type="radio" name="Questions" value="4">
Barcelona</label>
<br>
</p>
<input name="Check" type="submit" value="Check">
</form>
</font id=code></pre id=code>
<a href="www.code-z.co.uk" title="Code-Z :: Digital Media & Content Creation"><img src="www.code-z.co.uk/media/AffiliateLogo.jpg" border="0"></a>