Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Javascript (http://www.velocityreviews.com/forums/f68-javascript.html)
-   -   Firefox submits form on hit another button... (http://www.velocityreviews.com/forums/t921764-firefox-submits-form-on-hit-another-button.html)

Peet 12-06-2005 09:10 PM

Firefox submits form on hit another button...
 
Hi there,

Do somebody have some ideas about this behaviour?

I have a struts application. It has a jsp which has a form and two
buttons, one of them is html:submit, and the other is html:button.

Submit has to post the form, of course, that works correctly on all of
the browsers.
But the other button has an onclick event declared. It calls the
implemented javascript function in IE and in Opera, too, but Firefox
submits the form as well when I hit submit button...

Thanks in advance.
Peter


Tony 12-06-2005 10:02 PM

Re: Firefox submits form on hit another button...
 
>But the other button has an onclick event declared. It calls the
>implemented javascript function in IE and in Opera, too, but Firefox
>submits the form as well when I hit submit button...


onclick="doSomething();return false;"

Not tested, but should work.

"...submits the form as well when I hit submit button..."
Of course - it's a submit button!


web.dev 12-06-2005 11:02 PM

Re: Firefox submits form on hit another button...
 

Peet wrote:
> Hi there,
>
> Do somebody have some ideas about this behaviour?
>
> I have a struts application. It has a jsp which has a form and two
> buttons, one of them is html:submit, and the other is html:button.
>
> Submit has to post the form, of course, that works correctly on all of
> the browsers.
> But the other button has an onclick event declared. It calls the
> implemented javascript function in IE and in Opera, too, but Firefox
> submits the form as well when I hit submit button...
>
> Thanks in advance.
> Peter


When you have a button and you don't explicity declare a type for it,
the default type becomes a "submit" type. Other browsers honor this
except for IE, which defaults it to just a "button" type.

For example:

<form>
<button>
</form>

Except for IE, browsers will do a submit when the button is clicked.

<form>
<button type = "button">
</form>

Now, when you click on the button it will not do a submit.


Peet 12-06-2005 11:03 PM

Re: Firefox submits form on hit another button...
 
Thanks a lot, Tony, it works! :o)

You wrote:
"Of course - it's a submit button! "
I thought button-type button is differs from submit-type button to be
able to make difference between them... And, with any other browsers,
the sam page has worked correctly, just Firefox needs this solution.
But returning false after onclick() has resolved my problem.
Thanks again :)

Peter



All times are GMT. The time now is 01:11 PM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57