option buttons logic

L

lpjennifer

I am not too familiar with scripts but I wanted to see if
i could get an example or some help on a new page of my
website. It is just a simple survey.. about 10 questions
with option buttons only (as answers). I don't know where
to begin with the code.. i have the format of the page all
done I just have to add the code where it checks the value
(if the correct answer was selected) of each answer. Then
at the end I tally up the total right, then I open a new
window.. depending on the number correct. Thanks in
advance.. i hope someone can help me out with this one.
 
J

Jim Buyens

This is going to be tough if you're not too familiar with
scripts. To do this in an ASP page, however, you'd:

1. Set up each set of option buttins with the same
name, but different values. For example:

<input type="radio" name="Q1" value="A">
<input type="radio" name="Q1" value="B">
<input type="radio" name="Q1" value="C">
<input type="radio" name="Q1" value="D">

<input type="radio" name="Q2" value="T">
<input type="radio" name="Q2" value="F">

and so forth

2. Add some code like this to the page that processes
your form submission.

<%
Dim numcorr
numcorr = 0
If Request("Q1") = "C" Then numcorr = numcorr + 1
If Request("Q2") = "T" Then numcorr = numcorr + 1
If Request("Q3") = "B" Then numcorr = numcorr + 1
' check for additional correct answers here.
select case numcorr
case 9,10
response.redirect "grade-a.htm"
case 7,8
response.redirect "grade-b.htm"
case 5,6
response.redirect "grade-c.htm"
case 3,4
response.redirect "grade-d.htm"
case else
response.redirect "grade-f.htm"
end select
%>

Jim Buyens
Microsoft FrontPage MVP
http://www.interlacken.com
Author of:
*----------------------------------------------------
|\---------------------------------------------------
|| Microsoft Office FrontPage 2003 Inside Out
|| Microsoft FrontPage Version 2002 Inside Out
|| Web Database Development Step by Step .NET Edition
|| Troubleshooting Microsoft FrontPage 2002
|| Faster Smarter Beginning Programming
|| (All from Microsoft Press)
|/---------------------------------------------------
*----------------------------------------------------
 
Top