Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help with quiz for website

Status
Not open for further replies.

fincha7

Technical User
Nov 16, 2007
2
CA
i am new to java script and i am trying to create a quiz for my site if some one oculd please look over my code and tell me where i went wrong that would be great. thank you.

<html>
<Head>
<title>Internet Quiz</title>

//<JavaScript Document>
<script language="Javascript" type+"text/javascript">

function answerCorrect(questionNumber, answer)
{
var correct = flase

if (answer == answers[questionNumber])
correct = true;

return correct;
}

var questions = new Array();
var answeres = new Array ();

question[0]= new array();

questions[0][0] = "Face has ______ users";

questions[0][1] = "2 million users";

questions[0][2] = "10 million users";

questions[0][3] = "23 million users";

questions[0][4] = "42 million users";

answer[0] = "D";

questions [1] = new Array();
questions[1][0] = "insert question";
questions[1][1] = "insert awnser";
questions[1][2] = "insert awnser";
questions[1][3] = "insert awnser";
questions[1][4] = "insert awnser";

awnser[1] = "b";

</script>
</head>

<body>

<body>
</html>
 
I was going to document each error, but realised that:

- We have no idea where you're calling "answerCorrect",
- We have no idea what you're passing in to "answerCorrect",
- There are numerous typos and mis-spellings of variable names you're using throughout.

Those aside:

This is not valid HTML. You cannot use JS style comments outside of a JS block. Use HTML comments instead if you need to:
Code:
//<JavaScript Document>

This:
Code:
type[!]+[/!]"text/javascript"
should be:
Code:
type[!]=[/!]"text/javascript"

This:
Code:
var correct = [!]flase[/!]
should be:
Code:
var correct = [!]false[/!]

So, address those issues, then go through your code and fix all of your spelling mistakes on variable names. Perhaps run your code through a spell-checker (even your text has spelling mistakes in it!).

Hope this helps,
Dan


Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
sorry i was doing this at 4am the other night and didn't check it over for spelling mistakes. i will go in and change all of them and see if it works after. I am sorry for posting this.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top