Wednesday, January 14, 2009

IE6 Problem with Form Submit Image Buttons

A lot of times we use images as our submit buttons for forms. I'm sure you've seen it a lot. Well, say you wanted to test if the form was submitted and used the standard way, lets say in PHP, of seeing if the submit button was sent, for example like this:

if (isset($_REQUEST['mysubmitbutton']))
{ ...}

With IE6 this wouldn't work if your submit button was an image. So if you had this as your submit button:

<input name="mysubmitbutton" type="image" value="1" src="someimage.png" alt="" />

Then your script wouldn't work. The reason is that IE6 WILL NOT send over the variable mysubmitbutton.

The workaround is to know that IE6 will send over other information (along with all other browsers). It sends the x and y coordinates of where you clicked on the image. So you'll see mysubmitbutton_x and mysubmitbutton_y. So if you modify your code to look for either of these variables, you'll be good to go!

Credit is to be given to this discussion forum: Differences in form handling btw Mozilla and IE?

No comments: