Forum Moderators: coopster
I`m using one form with two input buttons, which was working fine:
<input type="submit" name="update" value="Update Template">
<input type="submit" name="restore" value="Restore Template">if (isset($_POST['update'])
{
code..
}
if (isset($_POST['restore'])
{
code
}
Like I say, working fine.
So, then I had the bright idea of creating images.
<input type="image" name="update" src="update.gif">
<input type="image" name="restore" src="restore.gif">
Unfortunately now the form processing does not work. Doesnt the form element name work the same with images? If I change it back, it works ok again.
Thanks.
Try
if (isset($_POST['restore'] ¦¦ isset($_POST['restore_x']))
{
code..
}
Note that PHP will turn the '.x' suffix into a '_x'...
If you have an image button
<input type="image" name="restore" value="Restore Template" src="...">
when the user clicks, Mozilla will return the values
restore = Restore Template
restore_x = number of pixels from top of image
restore_y = number of pixels from left edge of image
IE, however, will *not* return the restore=Restore Template key/value. So you can get caught if you develop in one browser and then test in IE, because
isset($_POST['restore'])
will always return false in IE, but will work as expected in Mozilla (and probably Opera but I don't know off the top of my head).
Tom
I had a similar problem with a JSP page. Form worked perfectly with a button with input type "submit", but wouldn't work with button an "image" type. Another image button on the same page DID work, however, which really boggled me. When I compared the two, I discovered that completely by accident, I had also assigned the working button an ID of "action". I then changed the other button to:
<input name="action" id="action" type="image" value="dummy" src="images/button.gif">
Lo and behold, it worked in IE and Netscape 7. I cannot explain it, I only know that it fixed the problem.