🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: fj.lang.javascript
Article #36

need help creating javascript quizzes

#36
From: ldeisia
Date: Mon, 18 May 1998 00:00
219 lines
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>&nbsp;</DIV>
<DIV>
<DIV>hello.&nbsp; i'm trying to figure out a way to create a quiz using=20
javascript.&nbsp; </DIV>
<DIV>&nbsp;</DIV>
<DIV>the person will either select an answer from a pop-down box or else =
type it=20
into a text box.&nbsp; (i will also consider using radio =
buttons)&nbsp;&nbsp;=20
the person will then click the submit button which will cause function=20
checkanswers to &quot;mark&quot; their work.&nbsp; </DIV>
<DIV>&nbsp;</DIV>
<DIV>i want to display whether they get the question correct or =
wrong.&nbsp; 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.&nbsp; actually a pop up window might be better for that =

purpose.</DIV>
<DIV>&nbsp;</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.&nbsp; below is the code i've tried most =

recently.</DIV>
<DIV>&nbsp;</DIV>
<DIV>also could you tell me which browsers currently support this =
code?</DIV>
<DIV>&nbsp;</DIV>
<DIV>please reply by email <A=20
href=3D"mailto:ldeisia@geocities.com">ldeisia@geocities.com</A><BR>thanks=
,<BR>shannon&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT =
color=3D#008000>&lt;html&gt;<BR>&lt;head&gt;<BR>&lt;title&gt;Garfield=20
Quiz&lt;/title&gt;</FONT>&nbsp;</DIV>
<DIV><FONT color=3D#008000></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#ff0000>&lt;script=20
language=3D&quot;javascript&quot;&gt;</FONT></DIV>
<DIV><FONT color=3D#ff0000></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#ff0000>var answers=3D&quot;&quot;;<BR>var=20
ans1=3Ddocument.garfield.1.value;<BR>var=20
ans2=3Ddocument.garfield.2.value;</FONT>&nbsp;</DIV>
<DIV><FONT color=3D#ff0000>function checkanswers(){</FONT></DIV>
<DIV><FONT color=3D#ff0000><BR>if (ans1=3D=3D&quot;Jon\'s aftershave=20
lotion&quot;){answers=3D&quot;1. Correct! &quot;}<BR>else =
{answers=3D&quot;1. False!=20
&quot;};</FONT>&nbsp;</DIV>
<DIV><FONT color=3D#ff0000></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#ff0000>if (ans2=3D=3D&quot;Jon\'s aftershave=20
lotion&quot;){answers+=3D&quot;2. Correct! &quot;}<BR>else =
{answers+=3D&quot;2.=20
False! &quot;}<BR>}</FONT>&nbsp;</DIV>
<DIV><FONT color=3D#ff0000></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#008000><FONT=20
color=3D#ff0000>&lt;/script&gt;</FONT><BR>&lt;/head&gt;</FONT>&nbsp;</DIV=
>
<DIV><FONT color=3D#008000></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#008000>&lt;body background=3D&quot;&quot;=20
bgcolor=3D&quot;#ffffff&quot; text=3D&quot;#000000&quot; =
link=3D&quot;#008000&quot;=20
vlink=3D&quot;#808080&quot; alink=3D&quot;#80ff80&quot;&gt;<BR>&lt;FORM=20
name=3D&quot;<FONT =
color=3D#ff0000>garfield</FONT>&quot;&gt;</FONT></DIV>
<DIV><FONT color=3D#008000><BR>&lt;TABLE border=20
cellpadding=3D10&gt;</FONT>&nbsp;</DIV>
<DIV><FONT color=3D#008000></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#008000>&lt;TR&gt;&lt;TD&gt;What did Garfield drink =
when stowed=20
away in Jon's suitcase?&lt;/TD&gt;<BR>&lt;TD&gt;<BR>&lt;SELECT =
name=3D&quot;<FONT=20
color=3D#ff0000>1</FONT>&quot;&gt;<BR>&lt;OPTION&gt;--SELECT--<BR>&lt;OPT=
ION&gt;A=20
nice refreshing cola<BR>&lt;OPTION&gt;Jon's aftershave=20
lotion<BR>&lt;OPTION&gt;Jon's shoe polish<BR>&lt;OPTION&gt;A bottle of=20
shampoo<BR>&lt;/SELECT&gt;<BR>&lt;/TD&gt;&lt;/TR&gt;</FONT>&nbsp;</DIV>
<DIV><FONT color=3D#008000></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#008000>&lt;TR&gt;&lt;TD&gt;What did Garfield drink =
when stowed=20
away in Jon's suitcase?&lt;/TD&gt;<BR>&lt;TD&gt;<BR>&lt;input =
type=3Dtext size=3D30=20
NAME=3D&quot;<FONT=20
color=3D#ff0000>2</FONT>&quot;&gt;<BR>&lt;/TD&gt;&lt;/TR&gt;</FONT>&nbsp;=
</DIV>
<DIV><FONT color=3D#008000></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#008000>&lt;/TABLE&gt;</FONT></DIV>
<DIV><FONT color=3D#008000></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#008000>&lt;P&gt;</FONT></DIV>
<DIV><FONT color=3D#008000>&lt;center&gt;<BR>&lt;INPUT TYPE=3DSUBMIT =
VALUE=3D&quot;=20
Score My Quiz &quot; <FONT =
color=3D#ff0000>onClick=3D'checkanswers()'</FONT>&gt;=20
<BR>&lt;INPUT TYPE=3DRESET VALUE=3D&quot; Clear Quiz=20
&quot;&gt;&lt;BR&gt;<BR>&lt;/center&gt;<BR>&lt;/FORM&gt;</FONT>&nbsp;</DI=
V>
<DIV><FONT color=3D#008000></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#008000><FONT color=3D#ff0000>&lt;script=20
language=3D&quot;javascript&quot;&gt;&lt;!--<BR>document.write(answers);<=
BR>//--&gt;<BR>&lt;/script&gt;</FONT></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#008000></FONT>&nbsp;</DIV>
<DIV><FONT=20
color=3D#008000>&lt;/body&gt;<BR>&lt;/html&gt;<BR></FONT>&nbsp;</DIV></DI=
V></BODY></HTML>

------=_NextPart_000_0046_01BD828D.6F99EC40--
Technical Details
Message-ID: <eHKaf8rg9GA.104@uppubnews03>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 103a72,cd16696ce45a715,start
X-Google-Attributes: gid103a72,public
From: "ldeisia" <ldeisia@mail.geocities.com>
Subject: need help creating javascript quizzes
Date: 1998/05/18
Message-ID: <eHKaf8rg9GA.104@uppubnews03>
X-Deja-AN: 354472055
MIME-Version: 1.0
Content-Type: multipart/alternative; boundary="----=_NextPart_000_0046_01BD828D.6F99EC40"
X-MimeOLE: Produced By Microsoft MimeOLE V4.71.1712.3
Newsgroups: fj.lang.javascript