Multiple submit buttons

N

Nik Coughin

With multiple submit buttons in IE, how do I tell which button has been
pressed?

If I do this in IE:

<form action="index.html">
<p>
<button name="move" value="up" type="submit">up</button>
<button name="move" value="down" type="submit">down</button>
</p>
</form>

I get:

index.html?move=up&move=down

I thought that if you had two submit buttons with the same name, it only
posted the name\value of the one that was clicked? I can't tell which one
it was from that.

It works in Opera. If I click the up button I get:

index.html?move=up

Does IE really not support multiple submit buttons, or have I overlooked
something?

--
"Come to think of it, there are already a million monkeys on a million
typewriters, and the Usenet is NOTHING like Shakespeare!" - Blair Houghton
-=-=-=-=-=-=-=-=-=-=-=-
http://www.nrkn.com/
-=-=-=-=-=-=-=-=-=-=-=-
 
B

brucie

In alt.html Nik Coughin said:
With multiple submit buttons in IE, how do I tell which button has been
pressed?

<button name="move" value="up" type="submit">up</button>
<button name="move" value="down" type="submit">down</button>

use different names
 
N

Nik Coughin

brucie said:
In alt.html Nik Coughin said:


use different names

Hi brucie.

If I use different names:

<form action="index.html">
<p>
<button name="moveUp" value="up" type="submit">up</button>
<button name="moveDown" value="down" type="submit">down</button>
</p>
</form>

I get:

index.html?moveUp=up&moveDown=down

....and I still can't tell which button was pressed. This is only with IE.

At the moment I am using this instead, as it works in IE:

<input name="move" value="down" type="submit">
<input name="move" value="up" type="submit">

By doing that, if I click up I get:

index.html?move=up

I have a feeling IE is broken in regards to using a button element in this
way. Guess I'll have to stick to input, which is annoying as it uses the
value as both value and caption.
 
B

brucie

In alt.html Nik Coughin said:
If I use different names:
<button name="moveUp" value="up" type="submit">up</button>
<button name="moveDown" value="down" type="submit">down</button>
I get:

index.html?moveUp=up&moveDown=down

use said:
I have a feeling IE is broken

go with that feeling
 
T

Toby Inkster

Nik said:
<form action="index.html">
<p>
<button name="move" value="up" type="submit">up</button>
<button name="move" value="down" type="submit">down</button>
</p>
</form>

IE's handling of <button> is broken. Use <input type="submit"> instead.
 
J

Jukka K. Korpela

Toby Inkster said:
IE's handling of <button> is broken. Use <input type="submit"> instead.

However, you still have a problem if the actual form contains text input
fields. Then browsers may behave as if a submit button had been clicked
on, if the user hits Enter in a text field, and you might not know which
button will be "simulated".

On the other hand, with the specific form above, there's the simple
option of using two links instead of any form or buttons.
 
N

Nik Coughin

Jukka said:
However, you still have a problem if the actual form contains text
input fields. Then browsers may behave as if a submit button had been
clicked on, if the user hits Enter in a text field, and you might not
know which button will be "simulated".

On the other hand, with the specific form above, there's the simple
option of using two links instead of any form or buttons.

That was just to illustrate the problem, but sounds like a good idea. Links
are cleaner and take up less space anyway.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top