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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Having Trouble with Submit()

Status
Not open for further replies.
Jan 21, 2011
8
CA
I have an education test page that calculates the paper score with JS. If the user fails to make a certain grade they get a message and if they succeed they get transfered to a printable certificate.

if(result<80){
alert("Sorry, you failed to meet the requirements so you will need to try the test again. If you continue to have trouble you may have to repeat the video program")
}

else if (result >=80) {
alert("Congratulations!")
}

}

The above code works. The code below doesn't.

if(result<80){
alert("Sorry, you failed to meet the requirements so you will need to try the test again. If you continue to have trouble you may have to repeat the video program")
}

else if (result >=80) {
document.forms.test.submit();
}

}

Funny thing is that it works fine on another page for a different course. Any suggestions? It sure has me stumped. I am not an IT person and am self-taught with everything I do but I am building some e-learning packages as part of a consulting practice.
 
On the surface this looks correct, so the question would be do you get any errors? Both IE and FF offer ways to check for this. IE from the yellow shield icon on the lower left of the browser, and FF through its error console.

Also: Do you have form with the name of "test" somewhere in your page?



----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Behind the Web, Tips and Tricks for Web Development.
 
Yes. The answers all calculate properly but when I click the submit button, I get an IE error with the yellow triangle that says Error on Page and the script stops. If I change the Submit() to an alert message, there is no error. It works great in another page.

Yes, the name of my form with the test questions is "test".
I have continued to work with it but cannot find a solution.
 
So what does the error say is wrong here, double click the yellow shield and see what the error says more specifically.


Because as long as there is a correctly constructed form with a name of test, then that should submit it.

Perhaps if you showing us your <form> code we would help a bit more.



----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Behind the Web, Tips and Tricks for Web Development.
 
Well, well, well. I learn sosmething new everyday. I never knew that I could click on the IE error and get an explanation! And all the hours I have spent looking myself.
Anyway, my form is now working. I have no idea what the problem was before but when I was working on it, I inadvertently deleted the field for the total score. I put it back in and all is working now.
It was there when I made my first post because I was checking the math calculations. Who knows eh? the important thing is that it is working now and you gave me some very valuable information.

Thank you, thank you, thank you [2thumbsup]
 
Glad its working now.

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Behind the Web, Tips and Tricks for Web Development.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top