[Javascript] IE onclick problem

tedd tedd at sperling.com
Sat Apr 19 11:14:57 CDT 2008


At 11:57 AM -0700 4/18/08, Howard Jess wrote:
The line you specify invokes the checkForm function, rather than
>referring to it, and sets the onsubmit property to false; notice
>that you get the alert prompt on first display of the page, *before*
>you hit submit.
>
>Try:
>    window.onload = function() {
>      var form = document.getElementById('a');
>      form.onsubmit = function() {return checkForm(form)};
>    }
>
>or if you don't like that, try:
>    window.onload = function() {
>      var form = document.getElementById('a');
>      function submitter() {
>        return checkForm(form);
>      }
>      form.onsubmit = submitter;
>    }
>


Another question -- what if you have two forms?

window.onload=function()
	{
	var form=document.getElementById('a');
	function submitter()
		{
		return checkForm(form)
		}
	form.onsubmit = submitter;
	var form=document.getElementById('b');
	function submitter()
		{
		return checkForm(form)
		}
	form.onsubmit = submitter;
	}

Doesn't work for two forms.

How can you have an unobtrusive onsubmit function tied to an unique 
id form on a document that contains several forms -- such that IF its 
submit button is clicked, then that form is processed (i.e., 
evaluated for content) while not processing the other forms?

Now, I can do this with an in-line:

onsubmit="return checkForm(this);"

for each form, but how do you do that and be unobtrusive?

Cheers,

tedd
-- 
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com
_______________________________________________
Javascript mailing list
Javascript at lists.evolt.org
http://lists.evolt.org/mailman/listinfo/javascript
-- 
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com



More information about the Javascript mailing list