http://www.webmasterworld.com Welcome to WebmasterWorld Guest from 38.103.63.18
register, login, search, glossary, subscribe, help, library, PubCon, announcements , recent posts, unanswered posts
SearchEngineWorld
Home / Forums Index / Browser Side World / HTML and Browsers
Forum Library : Charter : Moderators: BlobFisk & encyclo & tedster

HTML and Browsers

  
<input type="image"> problem
IE problem with form submission when using image input
jonesehh


#:598844
 10:33 pm on Feb. 17, 2005 (utc 0)
Been banging my head against a wall for a coupla days on this! I really don't think it should be this tricky!

I have a form that submits to a php script. I want to use image inputs instead of the usual submit button. On submission I want to test whether the image has been clicked (in my php script) to trigger other stuff. The problem I'm having is this:

In mozilla 1.0 and firefox, On clicking <input type="image" name="submit" value="1" src="whatever"> the following fields are posted to the server

submit.x=(x coordinate clicked on image)
submit.y=(y coordinate clicked on image)
submit=1

This is great cos I can test for submit=1 in my script.

The problem is in IE 6 (what a surprise). Clicking the image in IE seems to post:

submit.x=(x coordinate clicked on image)
submit.y=(y coordinate clicked on image)

Now I can't seem to successfully test for the existence of submit.x in php (presumably cos of the "."[smilestopper])

Any suggestions and I'd be really grateful. I really need this to work in IE.

Cheers

Nick

H2O_aa


#:598845
 4:51 pm on Feb. 18, 2005 (utc 0)

I've done this many times. All I needed was this:

<INPUT name="submit" type=image src="images/subbutton.jpg" width="350" height="24" border="0">

if ($_POST['submit_x'])
{
...............

}

So add "_x" to whatever the name of the image button. In your case, it's also "submit_x".

jonesehh


#:598846
 5:49 pm on Feb. 18, 2005 (utc 0)

Thanks so much. That really helped. I ended up testing for submit_x rather than using the $_POST global but it works fine.

Sorry to be a pain in the @ss but could you explain why the _ replaces the .? Just my lack of understanding of the syntax.

Thanks again

Nick

H2O_aa


#:598847
 12:03 am on Feb. 19, 2005 (utc 0)

I found the following explanation on a website.


When you submit your form with a graphic button, you will notice the .x and .y appended to the name of the button.

...snertal&crew%5B%5D=gosny&formbutton.x=37&formbutton.y=14

But if you were to submit the page and look at the results, however, you'd see:

formbutton_x = 37
formbutton_y = 14

Notice that the period (.) has been converted to an underscore (_). This may seem a little odd, but it's necessary because variable names in PHP can't have periods in them, so $formbutton.x would be an illegal variable name. In fact, any periods in form names -- not just those for image buttons -- are converted to underscores.

Maybe others can add their 2 cents too.

By the way, it's better for you to put anything related to PHP in the PHP forum.

jonesehh


#:598848
 9:48 am on Feb. 19, 2005 (utc 0)

Thanks for that. Will post further PHP stuff in the relevant forum. The reason I put the original post here was because I felt it was a browser/form submission issue.

Thanks again

Nick

 

Home / Forums Index / Browser Side World / HTML and Browsers
All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
WebmasterWorld ® and PubCon ® are a Registered Trademarks of WebmasterWorld Inc.
© WebmasterWorld Inc. / SearchEngineWorld 1996-2008 all rights reserved