开发者

Help needed with simple js quiz form! [duplicate]

This question already has answers here: Closed 12 years ago.

Possible Duplicate:

Help me fix my JavaScript Quiz

Hi, this javascript form isn't working as there is some kind of bug/error in the code which I can't find! It should activate a pop-up after answering the 4 questions and clicking the 'submit' button - letting the user know if they have passed or failed the little test.

Instead of posting all the code it is here in t开发者_如何学JAVAhe doc. head here: http://bit.ly/g4jO3J

Any help would be appreciated for this project.


You have a redundant onclick= in your submit button. Instead of:

<input name="button" type="Submit" onClick="onclick=return checkAnswers()" />

Use:

<input name="button" type="Submit" onClick="return checkAnswers()" />


Your script contains HTML:

<script>
// your code

<form name="Quiz" onsubmit="return validate(this)">
<input type="submit" />
</form>

</script>

That causes a syntax error. But that's probably not the problem.


  1. function validate(myForm) { => function validate() {

  2. var allQuestions = new Array(Quiz.q1,Quiz.q2,Quiz.q3,Quiz.q4); => var allQuestions = new Array(document.Quiz.q1,document.Quiz.q2,document.Quiz.q3,document.Quiz.q4);

  3. onClick="return checkAnswers()" => onClick="return validate()"


Thanks for your help - I got it working eventually!!

If anyone is looking for a simple javascript quiz then visit the page (link above) and click view source to see the code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜