> -----Original Message-----
> From: S. Isaac Dealey [mailto:[EMAIL PROTECTED]] 
> Sent: Sunday, December 15, 2002 11:04 PM
> To: CF-Talk
> Subject: Re: Mildly OT: JS, Form, Passing Vars
> 
> 
> > Also the onclick event may need to return true for the
> > form to actually submit. I didn't test this :) 
> > onclick="setFormParams(this.form, 'complete'); return true;"
> 
> My understanding / experience is that an onclick event only 
> prevents a form from submitting when it's in a submit button 
> with specifically this syntax:
> 
> onclick="return myfunction();"
> 
> and the function call returns false. ( Or you put return 
> false; on the end of the attribute, although I can't imagine 
> why you'd want to ) ...

That works - but only if the button is pressed.  Submitting the form
some other way like pressing the "enter" key) doesn't fire an event on
the submit button.

For this reason you should trap such things at the form level (using
onSubmit() and returning false should work).

If you're secure in your environment (MSIE 4+ will do this) you can also
take advantage (if the environment supports it) of event bubbling and
trap the submit at some higher level (like the body tag or a table tag).
This works well if you have many small forms on a page and want to trap
their submits for some reason.

Jim Davis


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Get the mailserver that powers this list at http://www.coolfusion.com

Reply via email to