nesianmysticfan
04-09-2004, 09:54 AM
Heres a totorial that I made which is how to make a javascript quiz.
Making the quiz
Ok, first you need to put this code onto your page anywhere:
<script><!-- hide
var ans = new Array;
var done = new Array;
var score = 0;
ans[1] = "a";
ans[2] = "a";
ans[3] = "a";
ans[4] = "a";
ans[5] = "a";
ans[6] = "a";
ans[7] = "a";
ans[8] = "a";
ans[9] = "a";
ans[10] = "a";
function Engine(question, answer) {
if (answer != ans[question]) {
if (!done[question]) {
done[question] = -1;
alert("Wrong!\n\nYour score is now: " + score);
}
else {
alert("You already answered that question");
}
}
else {
if (!done[question]) {
done[question] = -1;
score++;
alert("Right! \n\nYour score is now: " + score);
}
else {
alert("You already answered that question");
}
}
}
function NextLevel () {
if (score >= 7 && score <= 11) {
alert("Note if got 7 or more right ")
self.location="Address after ok click"
}
else {
alert("Note if scored less then 7")
}
}
//-->
</script>
you can edit the parts in bold and some of the other things too. now make the form by going:
<input type="radio" value="a" onclick="Engine(1, this.value)">
the engine part you have to edit to make it the right question. 1 means question 1. the value tells the code what answer it is (a,b,c) to tell if it was right or wrong. then when you have finished the questions, make a submit button by going:
<input type="button" value="The text you want the button to say" onclick="NextLevel()">
then save the page as a html page and it should work.
If you need anymore help, Private Message me.
Making the quiz
Ok, first you need to put this code onto your page anywhere:
<script><!-- hide
var ans = new Array;
var done = new Array;
var score = 0;
ans[1] = "a";
ans[2] = "a";
ans[3] = "a";
ans[4] = "a";
ans[5] = "a";
ans[6] = "a";
ans[7] = "a";
ans[8] = "a";
ans[9] = "a";
ans[10] = "a";
function Engine(question, answer) {
if (answer != ans[question]) {
if (!done[question]) {
done[question] = -1;
alert("Wrong!\n\nYour score is now: " + score);
}
else {
alert("You already answered that question");
}
}
else {
if (!done[question]) {
done[question] = -1;
score++;
alert("Right! \n\nYour score is now: " + score);
}
else {
alert("You already answered that question");
}
}
}
function NextLevel () {
if (score >= 7 && score <= 11) {
alert("Note if got 7 or more right ")
self.location="Address after ok click"
}
else {
alert("Note if scored less then 7")
}
}
//-->
</script>
you can edit the parts in bold and some of the other things too. now make the form by going:
<input type="radio" value="a" onclick="Engine(1, this.value)">
the engine part you have to edit to make it the right question. 1 means question 1. the value tells the code what answer it is (a,b,c) to tell if it was right or wrong. then when you have finished the questions, make a submit button by going:
<input type="button" value="The text you want the button to say" onclick="NextLevel()">
then save the page as a html page and it should work.
If you need anymore help, Private Message me.