Multiple image submit buttons and IE
Posted 2006-06-19 12:15 p.m. by mick
tags: internetexplorer programming web
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:
- If you clicked on one of the images then you got "action.x" and "action.y" but no actual action value.
- 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
Posted at 2006-07-10 1:10 p.m.
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
Posted at 2006-08-07 12:43 p.m.
thats heaps... I built my site using firefox, went to show it to someone using IE, well, you get the idea.
mikethecow
Posted at 2006-08-30 2:04 p.m.
Thanks a bundle for the zero and square brackets!!!
Sorts the same problem in Opera on PC btw
gadjodilo
Posted at 2006-10-04 8:45 a.m.
Super!! Thank you Abalam. I had the same problem, now it's working in both firefox and ie..
Regards,
gadjodilo
al
Posted at 2007-06-01 9:42 p.m.
fyi: The .x and .y are the (x,y) co-ordinates of where you clicked on the image.
Sam
Posted at 2007-09-22 2:18 p.m.
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.