Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-11-2006, 10:21 PM   PM User | #1
wilburforce
New Coder

 
Join Date: Sep 2006
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
wilburforce is an unknown quantity at this point
HELP variable report based on score

having difficulty in out putting a report based on a score eg:


if (totalscore.value > 40) { div.innerHTML = "very good score" ; }

if(totalscore.value > 30 && totalscore.value < 40) { div.innerHTML = "good score" ; }

if(totalscore.value <= 30) { div.innerHTML = "not good score" ; }

into this code, would be nice if i could tell them they missed a radio box as well and ideas how to do it?

<html>
<head>

<script type="text/javascript" language="JavaScript">


// On the next line, specify the number of answer choices at each question:
NumChoices = 5;

// Leave next five lines as is.
function CalculateScore()
{
var score = 0;
for (i = 0; i < NumChoices; i++)
{

// Begin calculation block.
// There should be one "if( ... value); }" line for each question. Each line needs to have the name
// of the form element specified in two places, in front of the open square brackets "["
if(document.quizform.Q1[i].checked) { score += parseInt(document.quizform.Q1[i].value); }
if(document.quizform.Q2[i].checked) { score += parseInt(document.quizform.Q2[i].value); }
if(document.quizform.Q3[i].checked) { score += parseInt(document.quizform.Q3[i].value); }
if(document.quizform.Q4[i].checked) { score += parseInt(document.quizform.Q4[i].value); }
if(document.quizform.Q5[i].checked) { score += parseInt(document.quizform.Q5[i].value); }
if(document.quizform.Q6[i].checked) { score += parseInt(document.quizform.Q6[i].value); }
if(document.quizform.Q7[i].checked) { score += parseInt(document.quizform.Q7[i].value); }
if(document.quizform.Q8[i].checked) { score += parseInt(document.quizform.Q8[i].value); }
if(document.quizform.Q9[i].checked) { score += parseInt(document.quizform.Q9[i].value); }
if(document.quizform.Q10[i].checked) { score += parseInt(document.quizform.Q10[i].value); }
// End calculation block.

// Leave the rest of the JavaScript code as is.
}
document.quizform.totalscore.value = score;
} // -->
</script>

<body bgcolor="white">
<div align="center">
<h3> Assessment</h3>
</div>
<blockquote>
<blockquote>
<p>Quiz intro ?</p>
<form name="quizform">
<br>
<table width="100%" border="1">
<tr>
<td height="408"><table width="100%" border="1">
<tr>
<td width="3%">&nbsp;</td>
<td width="3%">&nbsp;</td>
<td width="3%">&nbsp;</td>
<td width="3%">&nbsp;</td>
<td width="3%">&nbsp;</td>
<td width="5%">&nbsp;</td>
<td width="80%">&nbsp;</td>
</tr>
<tr>
<td align="center"><input type="radio" name="Q1" value="1"></td>
<td align="center"><input type="radio" name="Q1" value="2"></td>
<td align="center"><input type="radio" name="Q1" value="3"></td>
<td align="center"><input type="radio" name="Q1" value="4"></td>
<td align="center"><input type="radio" name="Q1" value="5"></td>
<td>&nbsp;</td>
<td>Question 1 </td>
</tr>
<tr>
<td align="center"><input type="radio" name="Q2" value="1"></td>
<td align="center"><input type="radio" name="Q2" value="2"></td>
<td align="center"><input type="radio" name="Q2" value="3"></td>
<td align="center"><input type="radio" name="Q2" value="4"></td>
<td align="center"><input type="radio" name="Q2" value="5"></td>
<td>&nbsp;</td>
<td>Question 1 </td>
</tr>
<tr>
<td align="center"><input type="radio" name="Q3" value="1"></td>
<td align="center"><input type="radio" name="Q3" value="2"></td>
<td align="center"><input type="radio" name="Q3" value="3"></td>
<td align="center"><input type="radio" name="Q3" value="4"></td>
<td align="center"><input type="radio" name="Q3" value="5"></td>
<td>&nbsp;</td>
<td>Question 1 </td>
</tr>
<tr>
<td align="center"><input type="radio" name="Q4" value="1"></td>
<td align="center"><input type="radio" name="Q4" value="2"></td>
<td align="center"><input type="radio" name="Q4" value="3"></td>
<td align="center"><input type="radio" name="Q4" value="4"></td>
<td align="center"><input type="radio" name="Q4" value="5"></td>
<td>&nbsp;</td>
<td>Question 1 </td>
</tr>
<tr>
<td align="center"><input type="radio" name="Q5" value="1"></td>
<td align="center"><input type="radio" name="Q5" value="2"></td>
<td align="center"><input type="radio" name="Q5" value="3"></td>
<td align="center"><input type="radio" name="Q5" value="4"></td>
<td align="center"><input type="radio" name="Q5" value="5"></td>
<td>&nbsp;</td>
<td>Question 1 </td>
</tr>
<tr>
<td align="center"><input type="radio" name="Q6" value="1"></td>
<td align="center"><input type="radio" name="Q6" value="2"></td>
<td align="center"><input type="radio" name="Q6" value="3"></td>
<td align="center"><input type="radio" name="Q6" value="4"></td>
<td align="center"><input type="radio" name="Q6" value="5"></td>
<td>&nbsp;</td>
<td>Question 1 </td>
</tr>
<tr>
<td align="center"><input type="radio" name="Q7" value="1"></td>
<td align="center"><input type="radio" name="Q7" value="2"></td>
<td align="center"><input type="radio" name="Q7" value="3"></td>
<td align="center"><input type="radio" name="Q7" value="4"></td>
<td align="center"><input type="radio" name="Q7" value="5"></td>
<td>&nbsp;</td>
<td>Question 1 </td>
</tr>
<tr>
<td align="center"><input type="radio" name="Q8" value="1"></td>
<td align="center"><input type="radio" name="Q8" value="2"></td>
<td align="center"><input type="radio" name="Q8" value="3"></td>
<td align="center"><input type="radio" name="Q8" value="4"></td>
<td align="center"><input type="radio" name="Q8" value="5"></td>
<td>&nbsp;</td>
<td>Question 1 </td>
</tr>
<tr>
<td align="center"><input type="radio" name="Q9" value="1"></td>
<td align="center"><input type="radio" name="Q9" value="2"></td>
<td align="center"><input type="radio" name="Q9" value="3"></td>
<td align="center"><input type="radio" name="Q9" value="4"></td>
<td align="center"><input type="radio" name="Q9" value="5"></td>
<td>&nbsp;</td>
<td>Question 1 </td>
</tr>
<tr>
<td align="center"><input type="radio" name="Q10" value="1"></td>
<td align="center"><input type="radio" name="Q10" value="2"></td>
<td align="center"><input type="radio" name="Q10" value="3"></td>
<td align="center"><input type="radio" name="Q10" value="4"></td>
<td align="center"><input type="radio" name="Q10" value="5"></td>
<td>&nbsp;</td>
<td>Question 1 </td>
</tr>
<tr>
<td colspan="4">&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>
<br>
<table width="100%" border="1">
<tr>
<td width="17%"><input name="button" type="button" onClick="CalculateScore()" value="Calculate Score"></td>
<td width="14%">Your Score
<input type="text" name="totalscore" size="4"> </td>
<td width="69%">Your Report
<label>
<textarea name="report" cols="50" id="report"></textarea>
</label></td>
</tr>
</table></td>
</tr>
</table>


<noscript>
<br><b>Because your browser is not JavaScript enabled, the score cannot be calculated.</b>
</noscript>
</p>

</form>




</blockquote>
</blockquote>

</body>
</html>
wilburforce is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:58 PM.


Advertisement
Log in to turn off these ads.