tags:

views:

143

answers:

5

Okay, so here's the scenario. I have a simple HTML page:

<html>
<head>
</head>
<body>
    <form action="submit.php" method="get">
     <input type="image" src="btn_getStarted.png" name="getStarted" value="btnBasic1" alt="Submit" />
    </form>
</body>
</html>

Along with the submit.php page:

<?php
    if(isset($_GET['getStarted'])) {
     echo "GOOD";
    }
    else {
     echo "BAD";
    }
?>

When submitting the form, I wold expect to be able to retrieve the value of getStarted, but that is not the case in IE.

Here are the URL's that are submitted:

Firefox: http://localhost/submit.php?getStarted.x=57&amp;getStarted.y=11&amp;getStarted=btnBasic1
IE8: http://localhost/submit.php?getStarted.x=50&amp;getStarted.y=21
IE6: http://localhost/submit.php?getStarted.x=67&amp;getStarted.y=14

I'm not really sure why IE is not receiving the btnGetStarted name from the input. Any help would be greatly appreciated. Thanks.

A: 

Your value tag is set to "btnBasic1", so IE passes that as the value for getStarted.

mfabish
value attribute rather
mfabish
Well, apparently *not* (according to the OP).
Konrad Rudolph
But, as you can see from the above URL's, "btnBasic1" isn't passed in IE.
+6  A: 

The input is sent through as the x and y coordinates that were clicked on.

Since "." isn't a valid identifier character in PHP it's converted to "_" (this preserves compatability with register_globals).

So you need to check for $_GET['getStarted_x']

Greg
Thanks Greg. Rather than checking whether the form was submitted (by checking 'getStarted_x', I was wanting to retrieve the value of the button (getStarted), which is passed in Firefox, but no IE. Is this just an IE thing?
IE and others (older ones at least).
Greg
+2  A: 

You're right. That's just how IE works. The .x and .y are the coordinates on the image that you clicked. You can use an image as an image map that way.

To do what you want, I recommend checking whether a different input variable has been set on your submit.php. You can add a hidden field especially for this, or use another input from your form.

Scott Saunders
Okay, so this is just a weird IE thing? I was unsure if it was something that I was doing.
No, not you. Just one of the fun browser incompatibilities we all get to deal with.
Scott Saunders
Yay. Life is great.
A: 

This is one of those lovely IE "features".

You can't collect a value of a posted input image.

If you really want to get the posted value use a <button> element with an image inside. Else just check for the existance of the x or y value

Jim Wardlaw
Well, I thought about trying that, but in IE, the URL will be: http://localhost/submit.php?getStarted=%3CIMG+alt%3D%22Get+Started+Button%22+src%3D%22btn_getStarted.png%22%3E
+1  A: 

After all, you apparently just want a button with a background image, not a button with an image map. In this case replace type="image" by type="submit" and use CSS to style it with a background image.

BalusC
I would recommend this solution. Alternatively, you can use `button` and decorate it by placing an `img` tag in it and/or using CSS.
Paul Lammertsma