469,602 Members | 1,912 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,602 developers. It's quick & easy.

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

Dec 6 '05 #1
3 1625
>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!

Dec 6 '05 #2

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.

Dec 6 '05 #3
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

Dec 6 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Andrea | last post: by
7 posts views Thread by mohammed.naghman | last post: by
7 posts views Thread by pbx | last post: by
3 posts views Thread by CAG | last post: by
2 posts views Thread by TheSouthLondonSlasher | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.