webmaster1 Posted April 5, 2009 Share Posted April 5, 2009 Hi All, I'm using an image as submit that has a mouseover effect but it doesn't trigger my php code when clicked; <input name="submit" id="submit" type="image" alt="Send Message" src="images/general_sendmessage1.jpg" srcover="images/general_sendmessage2.jpg" srcdown="images/general_sendmessage1.jpg" border="0"> It works fine when I use this: <input name="submit" id="submit" type="submit"/> Any ideas why its not working? i'm more interested in understanding whats going wrong rather than its fix. Link to comment https://forums.phpfreaks.com/topic/152653-solved-image-as-submit-button-wont-work/ Share on other sites More sharing options...
webmaster1 Posted April 5, 2009 Author Share Posted April 5, 2009 Righto. So far I've found out its an IE 6+ issue. Apparently server side gets the following info from input type="image': control_name => value control_name_x => x co-ord control_name_y => y co-ord i've been told to test for existence of x or y by doing the following: <?php if (isset($_POST["control_name_x"])) { // form submitted } ?> i'm not very certain of what it is I'm supposed to be doing here. http://www.aaronreynolds.co.uk/using-an-image-submit-button-in-php/ Link to comment https://forums.phpfreaks.com/topic/152653-solved-image-as-submit-button-wont-work/#findComment-801683 Share on other sites More sharing options...
PFMaBiSmAd Posted April 5, 2009 Share Posted April 5, 2009 The HTML specification only requires that x,y coordinates where the image is clicked to be sent to the server. Some browsers only supply that information while other browsers supply the value="..." as well. To make your code work for all browsers, only expect the x,y coordinates - http://us.php.net/manual/en/faq.html.php#faq.html.form-image or use a hidden field with a specific name/value that your code will use to detect that the form has been submitted. The problem is not an IE problem. IE and a couple other major browsers follow the specification. Browsers that send the value="..." are doing their own thing outside the specification. Link to comment https://forums.phpfreaks.com/topic/152653-solved-image-as-submit-button-wont-work/#findComment-801684 Share on other sites More sharing options...
webmaster1 Posted April 5, 2009 Author Share Posted April 5, 2009 I really don't know what you mean by expect the x,y coordinates or use a hidden field with a specific name/value that your code will use to detect that the form has been submitted. The theory makes sense but I don't know where to start in terms of implementation. Am I editing the name of the image or how I call it in the isset condition? Link to comment https://forums.phpfreaks.com/topic/152653-solved-image-as-submit-button-wont-work/#findComment-801686 Share on other sites More sharing options...
webmaster1 Posted April 5, 2009 Author Share Posted April 5, 2009 I added _x to the to isset condition and everything is hunky dory. Could someone finally explain why the x is required only and not the y too? (Thanks for the help PFMaBismAd!!!) Link to comment https://forums.phpfreaks.com/topic/152653-solved-image-as-submit-button-wont-work/#findComment-801689 Share on other sites More sharing options...
PFMaBiSmAd Posted April 5, 2009 Share Posted April 5, 2009 If you receive two values that both indicate the image was clicked, why would you need to check more than one of them? You would only use both if you were actually checking the coordinate values where the image was clicked. Link to comment https://forums.phpfreaks.com/topic/152653-solved-image-as-submit-button-wont-work/#findComment-801693 Share on other sites More sharing options...
webmaster1 Posted April 5, 2009 Author Share Posted April 5, 2009 two values that both indicate the image was clicked So just the one is enough to indicate. Thanks again. Link to comment https://forums.phpfreaks.com/topic/152653-solved-image-as-submit-button-wont-work/#findComment-801697 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.