473,405 Members | 2,272 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

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 1718
>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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Andrea | last post by:
I am trying to alter css using javascript as well as use the innerHTML function. I have pasted below 3 forms that access getElementById in slightly different ways (I wanted to rule out that it was...
26
by: Jeremy | last post by:
Hi, say we have the code below on a button: <input type="button" class="btn" value="Continue" onclick="if (myform.p_name.value=='') alert('You must enter a name for the folder'); else {...
1
by: DarthOptimus | last post by:
Hi, There is javascript code on my jsp to prevent double submission of a form: <SCRIPT type="text/javascript" language="JavaScript"> var firstSubmit = true; function isFirstSubmit() {
17
by: SimonWilding | last post by:
I am using a line of javascript that both sets the value of a hidden input element (name='button') and then submits the form. The destination of the post can then pick up the value of the hidden...
7
by: mohammed.naghman | last post by:
Hi, I have 2 submit buttons in a jsp page. One of them takes me to page2.jsp and also passes the values enetered to page2.I have a link in the page2 that does a history.back to come to the...
7
by: pbx | last post by:
if I try: window.open(url, "_self"); in firefox (2.0x), firefox just refreshes the current window, it doesn't "goto" the url. this works fine in IE 6 or 7. anyone know what the deal is...
3
by: CAG | last post by:
Hello, I have following scenario in my web application. I want to load different web forms in single iframe. Iframe in contained in an ASP page. ASP page has “Submit” button, which submits iframe...
2
by: TheSouthLondonSlasher | last post by:
Thank you in advance to anyone who may be able to help. This is my first attempt at JavaScript, so I apologize if I've done something blatantly stupid in the below code. Basically, I have a form...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.