Thread View: fj.lang.javascript
1 messages
1 total messages
Started by ldeisia
Mon, 18 May 1998 00:00
need help creating javascript quizzes
Author: ldeisia
Date: Mon, 18 May 1998 00:00
Date: Mon, 18 May 1998 00:00
219 lines
8301 bytes
8301 bytes
This is a multi-part message in MIME format.
------=_NextPart_000_0046_01BD828D.6F99EC40
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
hello. i'm trying to figure out a way to create a quiz using =
javascript. =20
the person will either select an answer from a pop-down box or else type =
it into a text box. (i will also consider using radio buttons) the =
person will then click the submit button which will cause function =
checkanswers to "mark" their work. =20
i want to display whether they get the question correct or wrong. i =
want to have the corrections displayed either at the bottom of the page =
using document.write or else write the corrections into a new window =
that will pop up. i want to allow the person to compare the answers they =
wrote on the quiz with the corrections. actually a pop up window might =
be better for that purpose.
i've been working on this for a while and have tried a number of things =
but i haven't gotten it to work yet. below is the code i've tried most =
recently.
also could you tell me which browsers currently support this code?
please reply by email ldeisia@geocities.com
thanks,
shannon=20
<html>
<head>
<title>Garfield Quiz</title>=20
=20
<script language=3D"javascript">
=20
var answers=3D"";
var ans1=3Ddocument.garfield.1.value;
var ans2=3Ddocument.garfield.2.value;=20
function checkanswers(){
if (ans1=3D=3D"Jon\'s aftershave lotion"){answers=3D"1. Correct! "}
else {answers=3D"1. False! "};=20
=20
if (ans2=3D=3D"Jon\'s aftershave lotion"){answers+=3D"2. Correct! "}
else {answers+=3D"2. False! "}
}=20
=20
</script>
</head>=20
=20
<body background=3D"" bgcolor=3D"#ffffff" text=3D"#000000" =
link=3D"#008000" vlink=3D"#808080" alink=3D"#80ff80">
<FORM name=3D"garfield">
<TABLE border cellpadding=3D10>=20
=20
<TR><TD>What did Garfield drink when stowed away in Jon's suitcase?</TD>
<TD>
<SELECT name=3D"1">
<OPTION>--SELECT--
<OPTION>A nice refreshing cola
<OPTION>Jon's aftershave lotion
<OPTION>Jon's shoe polish
<OPTION>A bottle of shampoo
</SELECT>
</TD></TR>=20
=20
<TR><TD>What did Garfield drink when stowed away in Jon's suitcase?</TD>
<TD>
<input type=3Dtext size=3D30 NAME=3D"2">
</TD></TR>=20
=20
</TABLE>
=20
<P>
<center>
<INPUT TYPE=3DSUBMIT VALUE=3D" Score My Quiz " =
onClick=3D'checkanswers()'>=20
<INPUT TYPE=3DRESET VALUE=3D" Clear Quiz "><BR>
</center>
</FORM>=20
=20
<script language=3D"javascript"><!--
document.write(answers);
//-->
</script>=20
=20
</body>
</html>
=20
------=_NextPart_000_0046_01BD828D.6F99EC40
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML//EN">
<HTML>
<HEAD>
<META content=3Dtext/html;charset=3Diso-8859-1 =
http-equiv=3DContent-Type>
<META content=3D'"MSHTML 4.71.1712.3"' name=3DGENERATOR>
</HEAD>
<BODY>
<DIV> </DIV>
<DIV>
<DIV>hello. i'm trying to figure out a way to create a quiz using=20
javascript. </DIV>
<DIV> </DIV>
<DIV>the person will either select an answer from a pop-down box or else =
type it=20
into a text box. (i will also consider using radio =
buttons) =20
the person will then click the submit button which will cause function=20
checkanswers to "mark" their work. </DIV>
<DIV> </DIV>
<DIV>i want to display whether they get the question correct or =
wrong. i=20
want to have the corrections displayed either at the bottom of the page =
using=20
document.write or else write the corrections into a new window that will =
pop up.=20
i want to allow the person to compare the answers they wrote on the quiz =
with=20
the corrections. actually a pop up window might be better for that =
purpose.</DIV>
<DIV> </DIV>
<DIV>i've been working on this for a while and have tried a number of =
things but=20
i haven't gotten it to work yet. below is the code i've tried most =
recently.</DIV>
<DIV> </DIV>
<DIV>also could you tell me which browsers currently support this =
code?</DIV>
<DIV> </DIV>
<DIV>please reply by email <A=20
href=3D"mailto:ldeisia@geocities.com">ldeisia@geocities.com</A><BR>thanks=
,<BR>shannon </DIV>
<DIV> </DIV>
<DIV><FONT =
color=3D#008000><html><BR><head><BR><title>Garfield=20
Quiz</title></FONT> </DIV>
<DIV><FONT color=3D#008000></FONT> </DIV>
<DIV><FONT color=3D#ff0000><script=20
language=3D"javascript"></FONT></DIV>
<DIV><FONT color=3D#ff0000></FONT> </DIV>
<DIV><FONT color=3D#ff0000>var answers=3D"";<BR>var=20
ans1=3Ddocument.garfield.1.value;<BR>var=20
ans2=3Ddocument.garfield.2.value;</FONT> </DIV>
<DIV><FONT color=3D#ff0000>function checkanswers(){</FONT></DIV>
<DIV><FONT color=3D#ff0000><BR>if (ans1=3D=3D"Jon\'s aftershave=20
lotion"){answers=3D"1. Correct! "}<BR>else =
{answers=3D"1. False!=20
"};</FONT> </DIV>
<DIV><FONT color=3D#ff0000></FONT> </DIV>
<DIV><FONT color=3D#ff0000>if (ans2=3D=3D"Jon\'s aftershave=20
lotion"){answers+=3D"2. Correct! "}<BR>else =
{answers+=3D"2.=20
False! "}<BR>}</FONT> </DIV>
<DIV><FONT color=3D#ff0000></FONT> </DIV>
<DIV><FONT color=3D#008000><FONT=20
color=3D#ff0000></script></FONT><BR></head></FONT> </DIV=
>
<DIV><FONT color=3D#008000></FONT> </DIV>
<DIV><FONT color=3D#008000><body background=3D""=20
bgcolor=3D"#ffffff" text=3D"#000000" =
link=3D"#008000"=20
vlink=3D"#808080" alink=3D"#80ff80"><BR><FORM=20
name=3D"<FONT =
color=3D#ff0000>garfield</FONT>"></FONT></DIV>
<DIV><FONT color=3D#008000><BR><TABLE border=20
cellpadding=3D10></FONT> </DIV>
<DIV><FONT color=3D#008000></FONT> </DIV>
<DIV><FONT color=3D#008000><TR><TD>What did Garfield drink =
when stowed=20
away in Jon's suitcase?</TD><BR><TD><BR><SELECT =
name=3D"<FONT=20
color=3D#ff0000>1</FONT>"><BR><OPTION>--SELECT--<BR><OPT=
ION>A=20
nice refreshing cola<BR><OPTION>Jon's aftershave=20
lotion<BR><OPTION>Jon's shoe polish<BR><OPTION>A bottle of=20
shampoo<BR></SELECT><BR></TD></TR></FONT> </DIV>
<DIV><FONT color=3D#008000></FONT> </DIV>
<DIV><FONT color=3D#008000><TR><TD>What did Garfield drink =
when stowed=20
away in Jon's suitcase?</TD><BR><TD><BR><input =
type=3Dtext size=3D30=20
NAME=3D"<FONT=20
color=3D#ff0000>2</FONT>"><BR></TD></TR></FONT> =
</DIV>
<DIV><FONT color=3D#008000></FONT> </DIV>
<DIV><FONT color=3D#008000></TABLE></FONT></DIV>
<DIV><FONT color=3D#008000></FONT> </DIV>
<DIV><FONT color=3D#008000><P></FONT></DIV>
<DIV><FONT color=3D#008000><center><BR><INPUT TYPE=3DSUBMIT =
VALUE=3D"=20
Score My Quiz " <FONT =
color=3D#ff0000>onClick=3D'checkanswers()'</FONT>>=20
<BR><INPUT TYPE=3DRESET VALUE=3D" Clear Quiz=20
"><BR><BR></center><BR></FORM></FONT> </DI=
V>
<DIV><FONT color=3D#008000></FONT> </DIV>
<DIV><FONT color=3D#008000><FONT color=3D#ff0000><script=20
language=3D"javascript"><!--<BR>document.write(answers);<=
BR>//--><BR></script></FONT></FONT> </DIV>
<DIV><FONT color=3D#008000></FONT> </DIV>
<DIV><FONT=20
color=3D#008000></body><BR></html><BR></FONT> </DIV></DI=
V></BODY></HTML>
------=_NextPart_000_0046_01BD828D.6F99EC40--
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads