Edit Delete
I'm trying to get a simple numerical result from three
questions. One is a select box, the other two are
radio buttons. Ideally, I'd like the number result to
correspond to opening a particular html page, but for
now I can't even get the number result to work.
I'm using this code:
<script TYPE="text/javascript">
<--
var t;
function tot()
{
t=0;
for(i=0;i<3;i++)
{
for(j=1;j<4;j++)
{
if(eval("document.f.r"+j+"["+i+"].checked"))
t+=parseInt(eval("document.f.r"+j+"["+i+"].value"));
}
}
rpt=confirm("Your score is : "+t+"\n\nReset form ?");
if(rpt)document.f.reset();
}
// -->
and the form is looking like this:
----------
<FORM NAME="f">
<SELECT NAME="r1">
<OPTION NAME="r1" value="0" selected>-
SELECT AGE -</OPTION>
<OPTION NAME="r1" value="5">0-5</OPTION>
<OPTION NAME="r1" value="10">6-10</OPTION>
<OPTION NAME="r1"
value="20">11-15</OPTION>
<OPTION NAME="r1"
value="30">16-20</OPTION>
<OPTION NAME="r1"
value="40">21-35</OPTION>
</SELECT>
<input type="radio" NAME="r2" VALUE="2">FICTION
<input type="radio" NAME="r2"
VALUE="1">NON-FICTION
<input type="radio" NAME="r3" VALUE="1">MALE
<input type="radio" NAME="r3"
VALUE="2">FEMALE
<INPUT TYPE="button" VALUE="Get result"
ONCLICK="tot()">
----------
Doesn't seem to work at all, I would really appreciate
some help, perhaps it's just a syntax error I've
overlooked, being new to such things :-)
Any tips on how to get the browser to then display a
particular html page depending on the score would
also be appreciated if anyone is feeling generous.
Thanks so much,
in anticipation x
|