Multiple image submit buttons and IE

Ran into an interesting problem with Internet Explorer today. I had a simple form for adding and removing people using nice + and - graphics as the submit images.:

<form action="add_remove_user" method="post">
    <input type="text" name="username" value="" />
    <input type="image" alt="add" src="add.png"
        name="action" value="add" />
    <input type="image" alt="remove" src="delete.png"
        name="action" value="remove" />
</form>

Nothing too exciting there, however I was getting some odd results from IE:

  1. If you clicked on one of the images then you got "action.x" and "action.y" but no actual action value.
  2. If you hit enter then the action field wasn't present.

The first problem I couldn't figure out, so rather than mess around with javascript or other hacks I just changed the buttons back to plain submit ones.

The second problem still persisted, and it turns out you need a fake input field (see this article for more detail). So having stuck in my fake field you can hit enter and click the buttons.:

<form action="add_remove_user" method="post">
    <input type="text" name="username" value="" />
    <input type="text" name="fake" class="fakefield" value="" />
    <input type="submit" name="action" value="add" />
    <input type="submit" name="action" value="remove" />
</form>

I'm not entirely happy with either solution, but IE has ground me down to the point where I just want to fix a problem and move on, avoiding javascript fixes where I can (since javascript on IE introduces a whole new set of problems).

Comments

Abalam

Hello,

There's a trick for this damn idiot IE :

Use <input type="image" src="img.jpg" name="delete[0]" value="ABC" />

And instead of delete_x and delete_y you will have $_POST["delete"][0]="ABC"

Good luck from France !

Ian

thats heaps... I built my site using firefox, went to show it to someone using IE, well, you get the idea.

mikethecow

Thanks a bundle for the zero and square brackets!!!

Sorts the same problem in Opera on PC btw

gadjodilo

Super!! Thank you Abalam. I had the same problem, now it's working in both firefox and ie..

Regards,

gadjodilo

al

fyi: The .x and .y are the (x,y) co-ordinates of where you clicked on the image.

Tomas

Ablam: thanx for the tip! most wanted =)

Olivia

Good site

Sam

Thanks so much Abalam, you are the only one out of dozens of other forums and threads that have solved this agonizing problem.

Post a comment

Comment posting temporarily disabled, too much spam.