D
David Jubinville
Hi All,
I'm developing a 'testing' page for the current courseware solution I'm
working on. Currently I have a single page with each question residing in
it's own layer <DIV>. I want to make sure the users have selected the
correct answer before the next DIV appears. The validation code works fine
and there are no problems there. For what ever reason, I can't seem to get
it to return valid data as its value. Something like this:
<input type="button" name="Submit" value="Submit" class="btn" onClick="
if (document.q1.chq1[0].checked) {answer = 0};
if (document.q1.chq1[1].checked) {answer = 1};
if (document.q1.chq1[2].checked) {answer = 2};
if (document.q1.chq1[3].checked) {answer = 3};
if (document.q1.chq1[4].checked) {answer = 4};
alert ('Your answer was ' + document.q1.chq1[answer].value);
if (document.q1.chq1[answer].value='correct') {document.q1.style.visibility
= 'hidden'; document.q2.style.visibility = 'visible'}" />
And so on and so forth, until the end of the questions... At this point it
works fine - however - it progresses to the next question regardless of the
value (correct / incorrect).
Is there something I'm missing here?
I know there are probably a million better methods for testing this data, if
you feel so inclined as to let me know, I certainly would be appreciative.
<Big nasty source snippit below>
Thanks in advance!
David
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form name="q1">
<table width="65%" border="0" align="center" cellpadding="1"
cellspacing="0" style="font-size:85%; font-family:Geneva, Arial, Helvetica,
sans-serif;">
<tr>
<td height="50" align="center"
valign="middle" style=" border-bottom-width:1px; border-bottom-style:solid;
border-bottom-color:#FFCD00; border-right-width:1px;
border-right-style:solid; border-right-color:#FFCD00;
background-color:#F3F7F9;"><span class="bodyheadLarge">Q1</span></td>
<td height="50" colspan="3"
valign="bottom" style=" border-bottom-width:1px; border-bottom-style:solid;
border-bottom-color:#FFCD00; padding-left:0.1in" class="bodycopyRed">What
is the carrier signal used by
Digital
Cable Called?</td>
</tr>
<tr align="center" valign="top">
<td width="10%" rowspan="6"
style="border-right-width:1px; border-right-style:solid;
border-right-color:#FFCD00; background-color:#F3F7F9;;"> </td>
<td> </td>
<td colspan="2"
align="left"> </td>
</tr>
<tr align="center" valign="top">
<td width="8%"> <input type="radio"
name="chq1" value="incorrect" /></td>
<td width="82%" colspan="2"
align="left">Phase
Shift</td>
</tr>
<tr align="center" valign="top">
<td width="8%"> <input type="radio"
name="chq1" value="incorrect" /></td>
<td colspan="2" align="left">Digital
Signal</td>
</tr>
<tr align="center" valign="top">
<td width="8%"> <input type="radio"
name="chq1" value="correct" /></td>
<td colspan="2"
align="left">Quadrature
Amplitude Modulation (QAM)</td>
</tr>
<tr align="center" valign="top">
<td width="8%"> <input type="radio"
name="chq1" value="incorrect" /></td>
<td colspan="2" align="left">Analogue
Signal</td>
</tr>
<tr align="center" valign="top">
<td width="8%"> <input type="radio"
name="chq1" value="incorrect" /></td>
<td colspan="2" align="left">Amplitude
Modulation</td>
</tr>
<tr align="center" valign="top">
<td style="border-right-width:1px;
border-right-style:solid; border-right-color:#FFCD00;
background-color:#F3F7F9;;"> </td>
<td> </td>
<td colspan="2"
align="left"> </td>
</tr>
<tr align="center" valign="top">
<td colspan="4"
style="background-color:#F3F7F9;"><div align="right">
<input type="button" name="Submit"
value="Submit" class="btn" onClick="if (document.q1.chq1[0].checked) {answer
= 0}; if (document.q1.chq1[1].checked) {answer = 1}; if
(document.q1.chq1[2].checked) {answer = 2}; if (document.q1.chq1[3].checked)
{answer = 3}; if (document.q1.chq1[4].checked) {answer = 4}; alert ('Your
answer was ' + document.q1.chq1[answer].value); if
(document.q1.chq1[answer].value='correct') {document.q1.style.visibility =
'hidden'; document.q2.style.visibility = 'visible'}">
</div></td>
</tr>
</table>
</form>
</body>
</html>
I'm developing a 'testing' page for the current courseware solution I'm
working on. Currently I have a single page with each question residing in
it's own layer <DIV>. I want to make sure the users have selected the
correct answer before the next DIV appears. The validation code works fine
and there are no problems there. For what ever reason, I can't seem to get
it to return valid data as its value. Something like this:
<input type="button" name="Submit" value="Submit" class="btn" onClick="
if (document.q1.chq1[0].checked) {answer = 0};
if (document.q1.chq1[1].checked) {answer = 1};
if (document.q1.chq1[2].checked) {answer = 2};
if (document.q1.chq1[3].checked) {answer = 3};
if (document.q1.chq1[4].checked) {answer = 4};
alert ('Your answer was ' + document.q1.chq1[answer].value);
if (document.q1.chq1[answer].value='correct') {document.q1.style.visibility
= 'hidden'; document.q2.style.visibility = 'visible'}" />
And so on and so forth, until the end of the questions... At this point it
works fine - however - it progresses to the next question regardless of the
value (correct / incorrect).
Is there something I'm missing here?
I know there are probably a million better methods for testing this data, if
you feel so inclined as to let me know, I certainly would be appreciative.
<Big nasty source snippit below>
Thanks in advance!
David
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form name="q1">
<table width="65%" border="0" align="center" cellpadding="1"
cellspacing="0" style="font-size:85%; font-family:Geneva, Arial, Helvetica,
sans-serif;">
<tr>
<td height="50" align="center"
valign="middle" style=" border-bottom-width:1px; border-bottom-style:solid;
border-bottom-color:#FFCD00; border-right-width:1px;
border-right-style:solid; border-right-color:#FFCD00;
background-color:#F3F7F9;"><span class="bodyheadLarge">Q1</span></td>
<td height="50" colspan="3"
valign="bottom" style=" border-bottom-width:1px; border-bottom-style:solid;
border-bottom-color:#FFCD00; padding-left:0.1in" class="bodycopyRed">What
is the carrier signal used by
Digital
Cable Called?</td>
</tr>
<tr align="center" valign="top">
<td width="10%" rowspan="6"
style="border-right-width:1px; border-right-style:solid;
border-right-color:#FFCD00; background-color:#F3F7F9;;"> </td>
<td> </td>
<td colspan="2"
align="left"> </td>
</tr>
<tr align="center" valign="top">
<td width="8%"> <input type="radio"
name="chq1" value="incorrect" /></td>
<td width="82%" colspan="2"
align="left">Phase
Shift</td>
</tr>
<tr align="center" valign="top">
<td width="8%"> <input type="radio"
name="chq1" value="incorrect" /></td>
<td colspan="2" align="left">Digital
Signal</td>
</tr>
<tr align="center" valign="top">
<td width="8%"> <input type="radio"
name="chq1" value="correct" /></td>
<td colspan="2"
align="left">Quadrature
Amplitude Modulation (QAM)</td>
</tr>
<tr align="center" valign="top">
<td width="8%"> <input type="radio"
name="chq1" value="incorrect" /></td>
<td colspan="2" align="left">Analogue
Signal</td>
</tr>
<tr align="center" valign="top">
<td width="8%"> <input type="radio"
name="chq1" value="incorrect" /></td>
<td colspan="2" align="left">Amplitude
Modulation</td>
</tr>
<tr align="center" valign="top">
<td style="border-right-width:1px;
border-right-style:solid; border-right-color:#FFCD00;
background-color:#F3F7F9;;"> </td>
<td> </td>
<td colspan="2"
align="left"> </td>
</tr>
<tr align="center" valign="top">
<td colspan="4"
style="background-color:#F3F7F9;"><div align="right">
<input type="button" name="Submit"
value="Submit" class="btn" onClick="if (document.q1.chq1[0].checked) {answer
= 0}; if (document.q1.chq1[1].checked) {answer = 1}; if
(document.q1.chq1[2].checked) {answer = 2}; if (document.q1.chq1[3].checked)
{answer = 3}; if (document.q1.chq1[4].checked) {answer = 4}; alert ('Your
answer was ' + document.q1.chq1[answer].value); if
(document.q1.chq1[answer].value='correct') {document.q1.style.visibility =
'hidden'; document.q2.style.visibility = 'visible'}">
</div></td>
</tr>
</table>
</form>
</body>
</html>