kaos
01-18-2010, 02:01 AM
Hi
I have been trying to make an online quiz for my site. However, I have had some troble adding the score with JS. Here's what I got so far...
<html>
<head>
<title>Test</title>
</head>
<body>
<script>
var total = 0;
if (document.test.q1 === 'correct') {
total = total + 5;
}
else {
total = total + 0;
}
</script>
<form name="test">
<div id="q1">
<b>[1] HTML stands for:</b><br><br>
<input type="radio" name="q1" value="correct">Hyper Text Markup Language<br>
<input type="radio" name="q1" value="wrong">Hyper Tool Markup Language<br>
<input type="radio" name="q1" value="wrong">Hyper Text Transfer Prodical<br>
<input type="radio" name="q1" value="wrong">Hyperlinks & Text Mulnipulation Language<br>
<div align="right"><button onClick="showhide('results'); return(false);">Next</button></div>
</div>
<div id="results" style="display:none;">
<center><h1>You've Finished!</h1>
You Scored: <font color="red"><script>document.write(total);</script>%</font><br>
<script>
if (total>85) {
document.write("You should be proud!");
}
else if (total<85) {
document.write("Keep working on it!");
}
else {
document.write("");
}
</script>
</center></div>
</form>
</body>
</html>
Can anyone help me?
I have been trying to make an online quiz for my site. However, I have had some troble adding the score with JS. Here's what I got so far...
<html>
<head>
<title>Test</title>
</head>
<body>
<script>
var total = 0;
if (document.test.q1 === 'correct') {
total = total + 5;
}
else {
total = total + 0;
}
</script>
<form name="test">
<div id="q1">
<b>[1] HTML stands for:</b><br><br>
<input type="radio" name="q1" value="correct">Hyper Text Markup Language<br>
<input type="radio" name="q1" value="wrong">Hyper Tool Markup Language<br>
<input type="radio" name="q1" value="wrong">Hyper Text Transfer Prodical<br>
<input type="radio" name="q1" value="wrong">Hyperlinks & Text Mulnipulation Language<br>
<div align="right"><button onClick="showhide('results'); return(false);">Next</button></div>
</div>
<div id="results" style="display:none;">
<center><h1>You've Finished!</h1>
You Scored: <font color="red"><script>document.write(total);</script>%</font><br>
<script>
if (total>85) {
document.write("You should be proud!");
}
else if (total<85) {
document.write("Keep working on it!");
}
else {
document.write("");
}
</script>
</center></div>
</form>
</body>
</html>
Can anyone help me?