Trouble with radio buttons

liunx

Guest
Hi can someone please help? I have managed to create a multiple choice form with a submit button that when clicked goes to a new page. If I give you an example of what I have done you may begin to understand what I am trying to do!: <br />
<br />
I have 1 qn and three possible answers but as I am doing an instructional web site I have to give feedback on the wrong answers that the user may select. Therefore if they do select the wrong answer how do I get them to go to another web page when they have clicked on the submit button with a reason where they went wrong and an option to go back and try again!!! At the moment any option they click on takes them to the same web page. I hope if anyone reads this can understand what I am trying to do and is able to help...I am new at this!!...in fact I am so new I am posting my HTML as well as now my submit button isn't working and I really need HELP...Thanks for time given if any!!!<br />
p.s any constructive criticism gladly accepted<br />
<br />
<html><br />
<head><br />
<title>C.A.I Assignment</title><br />
</head><br />
<!-- written by Tina Hamer for C.A.I assignment, February 20th, 2002 --><br />
<body BGCOLOR="#87CEEB" TEXT="#000000" LINK="#800517" ><br />
<FORM METHOD="POST" ACTION="a:\hello\radioOneSafetyTest.html"><H1></h1><br />
<FORM METHOD="POST" ACTION="a:\hello\radioOneSafetyTest.html"><input type="hidden" name="SU" value="1"><input type="hidden" name="NQ" value="1"><input type="hidden" name="TQ" value="3"><H1><P align=center>A sample quiz</P></H1><br />
<br />
<FONT COLOR="red"><P align=center>A sample quiz</FONT> <br />
<P><P><br />
<br />
<p><br />
In this tutorial you will be asked several questions on areas surrounding the Theft Act. Most of the questions are multiple choice and some require you to select a video clip. <br />
<P><br />
<small>With thanks to Mark Hamer for his expert help!</small>.<br />
<P><H2></h2><br />
<FONT COLOR="red"><P align=center>Health and Safety</FONT><br />
<hr><i><FONT COLOR="red"><P align=center>This first question deals with personal safety search techniques that you could <br />
come across in your working environment.<hr></i></FONT> <br />
<P>1) You receive a call from central police station that alerts you to the fact that<br />
there is a suspect (who is a known drug addict) wandering the area that you are currently<br />
patrolling. Allegedly, he has just broken into a car on Watling Street. A description of<br />
the suspect is given. You then on your search come across the alleged suspect who fits <br />
the description of the said suspect. Using stop and search powers you approach the suspect and<br />
ask to search him. When he agrees to the said search how to you carry out the search?<br />
<p><br />
<blockquote><br />
<br />
<br />
</HEAD><br />
<br />
</blockquote><br />
</form><br />
<input type="radio" name="1" value="1"> Ask him to empty his pockets.<br />
<BR><input type="radio" name="1" value="2"> Thrust your hands into his pockets searching for a tool.<br />
<BR><input type="radio" name="1" value="3"> Ask him to remove his clothes.<br />
<BR><br />
<P ALIGN=CENTER><input TYPE="submit" Value="Mark my answer"></P></FORM><HR><p><br />
<select name='xxx'><option>THE HINT BOX (Click here for a hint)</option><option>Some drug addicts <br />
use needles to administer their drug.<br />
</option><option>.<br />
</option><option><br />
<p><br />
Back to <br />
<A href=http://www.htmlforums.com/archive/index.php/"a:\hello\safetyTest.html">IQ Samples</A>.<br />
<p><br />
Back to <br />
<A href=http://www.htmlforums.com/archive/index.php/"a:\hello\safetyTest.html">Subject Material</A>.<br />
<p><br />
<ADDRESS>Please e-mail any feedback to <br />
<A href=http://www.htmlforums.com/archive/index.php/"mailto:[email protected]"><br />
<!-- e --><a href="mailto:[email protected]">[email protected]</a><!-- e --><br />
</A><br />
</ADDRESS><br />
<HR><br />
</HTML><!--content-->Hi,<br />
<br />
This can be done easily using ASP, but you will probably need to do a little bit of reading.<br />
<br />
The form inputs would be sent to an ASP page. The ASP page would then work out which answer was given and redirect to a page depending on the answer.<br />
<br />
<br />
example ASP code: (workout.asp)<br />
<br />
<br />
<%<br />
Dim str1<br />
<br />
str1 = Request.Form("1")<br />
<br />
If str1 = "1" Then Response.Redirect "page1.html"<br />
If str1 = "2" Then Response.Redirect "page2.html"<br />
If str1 = "3" Then Response.Redirect "page3.html"<br />
%><br />
<br />
<br />
<br />
Form action would be, action="workout.asp"<br />
<br />
This is a very simpe method, but not the best way of doing it. Ideally you'd want all the possible output from answering the questions in one ASP page.<br />
<br />
Hope this helps.<br />
<br />
Jon<!--content-->Your submit button is probably not working because you have 2 FORM tags and then there is a closing form tag before the submit button. <br />
<br />
Forms can not be embedded. There can only be one opening form tag and one closing form tag for each seperate form. <br />
<br />
To accomplish what you want, using PERL code, you need to parse the input. Something along the same lines as jonirvine mentions, but using PERL instead of ASP. Assuming choice 1 is the correct answer:<br />
<br />
if ($FORM{'1'} eq "1") {$response = $FORM{'1'};}<br />
if ($FORM{'1'} eq "2") {$response = $FORM{'1'};}<br />
if ($FORM{'1'} eq "3") {$response = $FORM{'1'};}<br />
<br />
if ($FORM{'1'} ne "1") {<br />
print "You selected <b>$response</b>, that is the wrong answer. When searching a suspect you should blah blah blah.......";<br />
}<br />
<br />
else {<br />
print "You selected <b>$response</b>, that is the correct answer. When searching a suspect you should blah blah blah.......";<br />
}<br />
<br />
hope that gives you the general idea.<br />
<br />
Regards,<br />
Kevin<br />
<br />
[Edited by kevin on 03-26-2001 at 01:19 PM]<!--content-->In your FORM tags, the action= should point to a script, not an HTML document. You could just use HTML or HTML/JAVA code and use hyperlinks to accomplish what you are trying to do instead of trying to use a form with some type of server side script.<br />
<br />
Regards,<br />
Kevin<!--content-->
 
Back
Top