onlyican Posted August 6, 2007 Share Posted August 6, 2007 Hey people I have a form full of buttons Depending what button is pressed I am using image buttons Now I have hit a problem, in IE. Example I have 2 buttons <input type='image' name='ImageButton1' value='X' src='images/ImageBtnA.gif' /> <input type='image' name='ImageButton2' value='Y' src='images/ImageBtnB.gif' /> Now the PHP Stuff <?php $ImgBtn1 = isset($_POST["ImageButton1"]) ? $_POST["ImageButton1"] : ""; $ImgBtn2 = isset($_POST["ImageButton2"]) ? $_POST["ImageButton2"] : ""; if($ImageBtn1 != ""){ //Do some code, for when this button is pressed } if($ImageBtn2 != ""){ //Do some code, for when this button is pressed } ?> NOTE: I need the value of this as well In FF, this works fine In IE, its not working I don't print_r($_POST) I get something like ImageButton1_x => 2, ImageButton1_y => 6 (The X and Y values of where the button / image was pressed. But I need the name and value of the button which was pressed. Any ideas how to resolve this issue. Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted August 6, 2007 Share Posted August 6, 2007 yes - swap the image buttons for good old submit buttons and style them! Quote Link to comment Share on other sites More sharing options...
onlyican Posted August 6, 2007 Author Share Posted August 6, 2007 You can tell it is Monday, I did not even think of that. Cheers. Just working to make it cross browser friendly with the text as I need the value but do not want to show the value Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted August 6, 2007 Share Posted August 6, 2007 if you want cross browser friendly then normal submit buttons are the way to go IMO - beware - styling is not consistent - most MAC browsers don't like styleing buttons that much... Quote Link to comment Share on other sites More sharing options...
Crew-Portal Posted August 6, 2007 Share Posted August 6, 2007 <form> </form> tags are the best. Use submit and if you want to keep PHP put all in between echo tags! PS: 100 POST Yaa! Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted August 6, 2007 Share Posted August 6, 2007 <form> tags? for a submit button????? Have I missed something here? Quote Link to comment Share on other sites More sharing options...
onlyican Posted August 6, 2007 Author Share Posted August 6, 2007 I was thinking something <form> </form> is a MUST as it is a form and having HTM inside PHP Echo takes more Server load Why not use SHorthand echo <input name='X' value='<?=$MyValue;?>' /> Quote Link to comment Share on other sites More sharing options...
AndyB Posted August 6, 2007 Share Posted August 6, 2007 Oh dear, doesn't anyone understand what image buttons are and how they work? Image buttons work the same way as image maps - when clicked, they pass the x and y coordinate values of the click relative to the upper left corner of the image. Magic! Just like the html standard. Apparently IE complies and FF doesn't. The way to tell if an image button has been clicked is to determine if the value of the x or y coordinate exists in the passed array from the form. $_POST["ImageButton1"] doesn't do anything. The right (and working) way to do it is to test for $_POST['imageButton1_x'] (or _y). Quote Link to comment Share on other sites More sharing options...
onlyican Posted August 6, 2007 Author Share Posted August 6, 2007 I understand that. I believ FF does work the same if you use _x and _y as IE BUt I thought they work the same as normal submits as well. Quote Link to comment Share on other sites More sharing options...
AndyB Posted August 6, 2007 Share Posted August 6, 2007 BUt I thought they work the same as normal submits as well. No, they don't. They work as I described. Quote Link to comment Share on other sites More sharing options...
onlyican Posted August 6, 2007 Author Share Posted August 6, 2007 CSS Submit buttons it is then Font size 0 Color White, to blend in with the image Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted August 7, 2007 Share Posted August 7, 2007 the understanding of how image inputs is not the issue - its really down to why use them... MAC OS will put its own glass btton there anyway for image or submit. IMO submit buttons are easier to deal with as they 'behave' the same cross browser - as already oted in this thread images act as image maps and are dealt with differently by differnt browsers. So in order to reduce your workload I believe using the simple submit type is the way to go... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.