Jump to content

[SOLVED] Javascript Error: window.document.quizForm.submit is not a function


sKunKbad

Recommended Posts

This script is working, but I'm just wondering why the Firefox debugger is showing an error. The error is:

Javascript Error: window.document.quizForm.submit is not a function

 

The javascript is:

<script type='text/javascript'>function preValidate(Q1,Q2,Q3,Q4,Q5,Q6) {
var allcool = 'no';
for (var loop = 0; loop < window.document.quizForm.Q6.length; loop++) {
	if (window.document.quizForm.Q6[loop].checked == true) {
		allcool = 'yes';
	}
}
if (allcool == 'no') {
	alert('Go back and check that all questions were answered!');
	return false;
}
var allcool = 'no';
for (var loop = 0; loop < window.document.quizForm.Q5.length; loop++) {
	if (window.document.quizForm.Q5[loop].checked == true) {
		allcool = 'yes';
	}
}
if (allcool == 'no') {
	alert('Go back and check that all questions were answered!');
	return false;
}
var allcool = 'no';
for (var loop = 0; loop < window.document.quizForm.Q4.length; loop++) {
	if (window.document.quizForm.Q4[loop].checked == true) {
		allcool = 'yes';
	}
}
if (allcool == 'no') {
	alert('Go back and check that all questions were answered!');
	return false;
}
var allcool = 'no';
for (var loop = 0; loop < window.document.quizForm.Q3.length; loop++) {
	if (window.document.quizForm.Q3[loop].checked == true) {
		allcool = 'yes';
	}
}
if (allcool == 'no') {
	alert('Go back and check that all questions were answered!');
	return false;
}
var allcool = 'no';
for (var loop = 0; loop < window.document.quizForm.Q2.length; loop++) {
	if (window.document.quizForm.Q2[loop].checked == true) {
		allcool = 'yes';
	}
}
if (allcool == 'no') {
	alert('Go back and check that all questions were answered!');
	return false;
}
var allcool = 'no';
for (var loop = 0; loop < window.document.quizForm.Q1.length; loop++) {
	if (window.document.quizForm.Q1[loop].checked == true) {
		allcool = 'yes';
	}
}
if (allcool == 'no') {
	alert('Go back and check that all questions were answered!');
	return false;
}
window.document.quizForm.submit();}
</script>

 

and the form in the page is:

<form action="register.php" method="post" name="quizForm" id="quizForm">
   <div class='question'>
	<div class='listnumber'>

		 1 )  
	</div>
	<div class='listquestion'>
		 My appearance is most important because:
	</div>
	<div class="choice">
		 <input type="radio" name="Q1" value="I need to look good professionally" />  I need to look good professionally
	</div>
   </div>
   <div class='question'>

	<div class='listnumber'>
		 2 )  
	</div>
	<div class='listquestion'>
		 My current body weight is:
	</div>
	<div class="choice">
		 <input type="radio" name="Q2" value="I'm pretty close to my ideal weight now" />  I'm pretty close to my ideal weight now
	</div>

	<div class="choice">
		 <input type="radio" name="Q2" value="I'm within 25 pounds of my ideal" />  I'm within 25 pounds of my ideal
	</div>
   </div>

   <div class='question'>
	<div class='listnumber'>
		 3 )  
	</div>
	<div class='listquestion'>
		 My ideal body goal is:
	</div>
	<div class="choice">
		 <input type="radio" name="Q3" value="I just need to tone up" />  I just need to tone up
	</div>

	<div class="choice">
		 <input type="radio" name="Q3" value="I want to lose a dress / pant size" />  I want to lose a dress / pant size
	</div>
   </div>

   <div class='question'>
	<div class='listnumber'>
		 4 )  
	</div>
	<div class='listquestion'>
		 My experience with exercise programs has been:
	</div>
	<div class="choice">
		 <input type="radio" name="Q4" value="I'm too busy" />  I'm too busy
	</div>

	<div class="choice">
		 <input type="radio" name="Q4" value="I get discouraged when I don't get results" />  I get discouraged when I don't get results
	</div>
   </div>
   <div class='question'>
	<div class='listnumber'>
		 5 )  
	</div>
	<div class='listquestion'>
		 Have you ever considered cosmetic surgery?
	</div>

	<div class="choice">
		 <input type="radio" name="Q5" value="It seems risky" />  It seems risky
	</div>
	<div class="choice">
		 <input type="radio" name="Q5" value="It seems expensive" />  It seems expensive
	</div>
   </div>
   <div class='question'>
	<div class='listnumber'>
		 6 )  

	</div>
	<div class='listquestion'>
		 If I could change one thing about myself it would be my:
	</div>
	<div class="choice">
		 <input type="radio" name="Q6" value="Appearance" />  Appearance
	</div>
	<div class="choice">
		 <input type="radio" name="Q6" value="Self confidence" />  Self confidence
	</div>
   </div>
   <div id='thankyou'>
	<p>
		 Thank you for taking the quiz.
	</p>

   </div>
   <div id='button'>
	<button id='submit' type='submit' onclick='preValidate(window.document.quizForm.Q1.value,window.document.quizForm.Q2.value,window.document.quizForm.Q3.value,window.document.quizForm.Q4.value,window.document.quizForm.Q5.value,window.document.quizForm.Q6.value);return false;'><img src='buttons/GetYourAnalysis.jpg' alt='Get your Analysis' /></button>
   </div>
</form>

 

How can I fix this and still have the code work?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.