sKunKbad Posted December 18, 2007 Share Posted December 18, 2007 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? Quote Link to comment Share on other sites More sharing options...
sKunKbad Posted December 18, 2007 Author Share Posted December 18, 2007 I figured it out. The CSS ID of the submit button of the form can not be "submit", it must be named something else. I named it "zubmit" and everything is great. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.