Connecting Tech Pros Worldwide Help | Site Map

Firefox submits form on hit another button...

 
LinkBack Thread Tools Search this Thread
  #1  
Old December 6th, 2005, 08:25 PM
Peet
Guest
 
Posts: n/a
Default 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


  #2  
Old December 6th, 2005, 09:15 PM
Tony
Guest
 
Posts: n/a
Default Re: Firefox submits form on hit another button...

>But the other button has an onclick event declared. It calls the[color=blue]
>implemented javascript function in IE and in Opera, too, but Firefox
>submits the form as well when I hit submit button...[/color]

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!

  #3  
Old December 6th, 2005, 10:15 PM
web.dev
Guest
 
Posts: n/a
Default Re: Firefox submits form on hit another button...


Peet wrote:[color=blue]
> 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[/color]

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.

  #4  
Old December 6th, 2005, 10:15 PM
Peet
Guest
 
Posts: n/a
Default 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

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.