View Full Version : Form Input type =Image not passing in IE

02-07-2006, 07:28 PM
Does anyone know why IE does not pass image input variable values from a form in IE?
Does anyone know a work around for this?

Heres what I have:
A form with images as input fields. I would like for the person to click on the image and that submits the form. I've got it working and passing the value of the variable in Safari, Firefox and Netscape but not IE. The variable gets passed to the database and the next page in all the mentioned browsers except IE. I need a work around asap.

Any help would be greatly appreciated.
I must use the imagas as the submit buttons to pass the variable into the database to.

02-07-2006, 07:48 PM
Are you, by any chance, doing it like this?

<input name="imagesubmit" type="image" value="Whatever" src="image.gif" />

That should work in all browsers

02-07-2006, 07:52 PM
Yes, exactly like that. For whatever reason IE will not except the value of the variable from the Image Input Field. Again, It works with all other browsers. Currently I've had to set up a check box under the images and a validation script to check and make sure the boxes are checked but this is a ridiculous way of doing things, plus the checkboxes look ugly under the image input fields.

02-07-2006, 07:57 PM
Odd... I use that day by day with my IE... with no problems...
If the only thing that doesn't get sent is the value (value shouldn't be set by you as the value is the x,y position of the mouseclick) you can use a hidden field...

02-07-2006, 08:07 PM
I'm trying to pass the input variable to php and send it into a mysql db. It is odd. But my jaw nearly hit the floor at 3am when 50 people had already used an online sweepstakes form I set up and none of the values from the input>type>image field were getting passed. I noticed some were and some were not. I ran tests in safari never even thinking IE would have this sort of issue. I ran tests in firefox and netscape and noticed the value getting passed to the db no problem. I then ran a test in IE to see if the value of the image variable would even get passed on the same page to the confirmation notice and it did not in IE. I tried it in the other browsers and they had no problems with it. I have no idea what it could be and thats what brought me to this forum. I tried posting on php-forum.com but they have been slow to respond. Any help out there would be greatly appreciated. I've got a temp work around in place but I don't want check boxes underneath each image.

02-07-2006, 08:08 PM
what code are you using to catch the submit on your form action page ?
IE (and I thought ff as well?) does not submit the name of the image as expected ... ($_POST['moveup'])

it submits
$_POST['moveup.x'] and $_POST['moveup.y']
(the co-ordinates of the mouseclick)
which PHP turns into
$_POST['moveup_x'] and $_POST['moveup_y']

so your PHP needs to check for..

PHP Code:
//form was submitted

Is what fire said in another post (replied to mine) this worked! Hope it helps you

02-07-2006, 08:09 PM
P.S. I'm not looking for the x or y coordinates on an image input field. I'm using the input>type>image as the submission button for the form. There are 8 images each with a value of a president. The values are not getting passed for whatever reason from the input>type>image but are able to get passed from the input>type>checkbox.

02-07-2006, 08:13 PM
Here is the code for one of the image input fields (- the ") :
<input type=\"image\" name=\"president\" value=\"george_washington\" src=\"images/george_washington.gif\" onclick=\"MM_validateForm('email','','RisEmail');return document.MM_returnValue\" />

The quote marks are because its in a php script. Anyway the php script (after the form is submitted) take the values from the form input fields and inserts them into a db. So far all the information is captured using IE except for the <input type=image value=somePresident name=president>.

07-10-2008, 01:21 PM
I had the same problem, but came up with a solution using a little onclick script:

<form method="post">
<input type="hidden" name="select" value="" />
<input type="image" name="submit" value="somePresident" src="president.gif" onclick="this.form.select.value = this.value" />

with this you can add as many input images you like. (I do this with a for-loop in my php-script, so they all get the same name, but that does not really matter..)
When you click an image the value YOU have set for THAT image is transfered to the hidden input-field before the form is submitted.

This gives the following post: select=somePresident&submit.x=37&submit.y=23

Then you can test the $_POST['select'] variable instead of the $_POST['submit'] (which IE does not give you)

I know that this solution kind of makes the use of image inputs pointless, but as long as there are IE-users it is probably the best solution.
IE probably thinks that image-inputs is only ment for image-maps or something...

07-10-2008, 03:43 PM
I'm not looking for the x or y coordinates on an image input fieldWe know that is not what you are doing, but the posts in this thread were telling you how an image as a submit button works and how you need to detect this in the php code so that it works in all browsers (the browsers where your existing code works are actually not following the standards this time). Read this (basically says what jeromepelletier posted) - http://www.php.net/manual/en/faq.html.php#faq.html.form-image

07-11-2008, 02:17 PM
(the browsers where your existing code works are actually not following the standards this time). Read this (basically says what jeromepelletier posted) - http://www.php.net/manual/en/faq.html.php#faq.html.form-image

I hate to be pedantic, but this is not entirely correct.. :)
what php.net says is true for php's part, but they do not set the standards for HTML. they can merely tell you how php will interpret the http-request.

the world wide web consortium (W3C) says this about input elements:

value = cdata [CA]
This attribute specifies the initial value of the control. It is optional except when the type attribute has the value "radio" or "checkbox".

from this I gather that IE is the standard-breaker as it does not pass the optional value attribute which the HTML-standard offers.
All browsers (i think) including IE passes the x and y coords, but that is a different attribute than the value.

07-11-2008, 04:32 PM
Getting picky, but the specification supports what IE is doing. The value="..." parameter is only the initial value. When the the form is submitted the name of the control is paired with its' current value. In the case of an image, its' current value is the click coordinates -

Creates a graphical submit button. The value of the src attribute specifies the URI of the image that will decorate the button. For accessibility reasons, authors should provide alternate text for the image via the alt attribute.
When a pointing device is used to click on the image, the form is submitted and the click coordinates passed to the server. The x value is measured in pixels from the left of the image, and the y value in pixels from the top of the image. The submitted data includes name.x=x-value and name.y=y-value where "name" is the value of the name attribute, and x-value and y-value are the x and y coordinate values, respectively.

Strictly following what the specification states about what is submitted for successful controls, you can expect name.x and name.y to be sent for an image.

01-07-2009, 09:55 PM
We attempt to avoid use of Java where possible (thinnest client & all that); I struggled with this issue for an invoice form that has multiple submit points:
name/value=account -> populate with the customer's info
name/value=update -> update the current line item
name/value=edit -> go back and edit an existing line item
name/value=delete -> delete the line item

These are in addtion to the standard submit and cancel buttons for the invoice as a whole. I'm handling the input this way:

switch (true) {
case array_key_exists('account_x', $_POST) :
// retrieve customer info and populate fields
case array_key_exists('edit_x', $_POST) :
// go to the requested line item
case array_key_exists('update_x', $_POST) :
// update the current line item
after suitably cleaning the $_POST variable, of course.


01-26-2010, 03:25 PM
$Button = "1";
$Button = "2";

NOW you know which button was hit.

01-02-2011, 08:33 PM
I had the same problem and an easy solution is to use a normal submit button with your image as background

i used:

<input type='submit' name='go_search' value='yes' style='border: 0px solid #FFFFFF; background-color:#E0ECF8; background-image: url(images/ico_search_29x32.gif); height: 32px; width: 29px;' alt='Rechercher'>
my image size is 29X32 px and I used background-color:#E0ECF8 because it's the background of my page.

It works with IE and mozila.
with php:
echo $_POST['go_search' ];==> yes

01-03-2011, 03:13 AM
What is this? A new tradition to bump this thread after a year?