Hi
I am creating a quiz using javascript which uses prompts and I am having a little difficulty setting atime limit for a user to answe each question. An example of some of my code is below:
[CODE]
<html>
<head>
<title>Quiz</title>
<script language=”JavaScript”>
setTimeout(“Times Up!”,60000);
alert(“You are about to play a multiple choice quiz game.nPlease answer a,b,c or d nYou have one minute to finish the quiznClick OK to play”)
var count= 0;
var quest1=prompt(“Question 1: What does goku turn into?nA) Supersaiyan.nB) namekien.nC) Yardratian.nD) Giant Ape.”);
var quest2=prompt(“Question 2: What is vegeta’s home planet callednA) Saiyan.nB) VegetanC) Namek.nD) Ovatronpercyi8″);
</script>
</head>
<body>
<h1>Comics 4 U – Multiple Choice Quiz</h1>
<h3> Your answers were…</h3>
<script type=”text/javascript”>
if ((quest1 == “a”) || (quest1 == “A”))
{
document.write(“Question 1 … What does goku turn into? <font color=’green’>” + quest1 + “)Supersaiyan.</font> is … CORRECT!!!!!!!!!!<br /><br />”);
count += 2;
}
else
{
document.write(“Question 1 … What does goku turn into? <font color=’red’>” + quest1 + “</font> is … WRONG!!!!!!!!!<br />The correct answer is <font color=’blue’>A) Supersaiyan.</font>.<br /><br />”);
count -= 1;
}
if ((quest2 == “b”) || (quest2 == “B”))
{
document.write(“Question 2: What is vegetas home planed called? <font color=’blue’>” + quest2 + “) vegeta.</font> is … CORRECT!!!!!!!!!!<br /><br />”);
count += 2;
}
else
{
document.write(“Question 2: What is vegetas home planet called? <font color=’red’>” + quest2 + “</font> is … WRONG!!!!!!!!!<br />The correct answer is <font color=’blue’>B) vegeta.</font>.<br /><br />”);
count -= 1;
}
document.write(“Your score is <font color=’blue’>” + count + “</font> out of 20!”);
if (count == 20)
{
document.write(“<br /><br />Congratulations you got them all right!!!”);
}
else
if ((count > 12) && (count < 20))
{
document.write(“<br /><br />You were close to getting them all right…Well done!!!”)
}
else
{
document.write(“<br /><br />Better luck next time…”);
}
</script>
</body>
</html>
Cna you please tell me where I am going wrong and how to create the timer for a time limit of 1 minute for each question?
Thanks if you can help.