Chrisj Posted June 17, 2013 Share Posted June 17, 2013 How do I add an image to this button? <input type="button" name="search" value="Search Again" onclick="window.location.href='page.php?page=9';" style="margin:7px 0" style="padding:1px 2px 1px 2px"> Quote Link to comment https://forums.phpfreaks.com/topic/279272-how-do-i-add-an-image-to-this-button/ Share on other sites More sharing options...
Psycho Posted June 17, 2013 Share Posted June 17, 2013 (edited) You don't. Buttons only support text. However, you can use an image tag to make it a input (i.e. button) <input type="image" src="sourceOfImage.jpg" name="search" onclick="window.location.href='page.php?page=9';" style="margin:7px 0;padding:1px 2px 1px 2px"> Note: an Image input does not have a value field. The x and y coordinates the user clicked in the image are passed as the value. Edited June 17, 2013 by Psycho 1 Quote Link to comment https://forums.phpfreaks.com/topic/279272-how-do-i-add-an-image-to-this-button/#findComment-1436449 Share on other sites More sharing options...
requinix Posted June 17, 2013 Share Posted June 17, 2013 Or you can use the often-overlooked which does support images. Quote Link to comment https://forums.phpfreaks.com/topic/279272-how-do-i-add-an-image-to-this-button/#findComment-1436466 Share on other sites More sharing options...
DavidAM Posted June 17, 2013 Share Posted June 17, 2013 Caution: Older versions of I.E. (6.0) used to POST all BUTTON elements on the form regardless of which one was pressed. I'm not sure if they have fixed this issue in later versions, but it made it very difficult (i.e. impossible) to determine which button was used to submit the form. Other than that, I like the BUTTON element. Quote Link to comment https://forums.phpfreaks.com/topic/279272-how-do-i-add-an-image-to-this-button/#findComment-1436471 Share on other sites More sharing options...
Chrisj Posted June 17, 2013 Author Share Posted June 17, 2013 Thanks for the replys. The Button worked, except the image has a black rectangle line border around it. How do I get rid of that? Quote Link to comment https://forums.phpfreaks.com/topic/279272-how-do-i-add-an-image-to-this-button/#findComment-1436493 Share on other sites More sharing options...
Chrisj Posted June 17, 2013 Author Share Posted June 17, 2013 Psycho's reply code didn't show a border, it showed the correct image, but when selected, it doesn't take me to href='page.php?page=9', it takes me to the location of another button in a line of code above it. Quote Link to comment https://forums.phpfreaks.com/topic/279272-how-do-i-add-an-image-to-this-button/#findComment-1436501 Share on other sites More sharing options...
requinix Posted June 18, 2013 Share Posted June 18, 2013 (edited) The Button worked, except the image has a black rectangle line border around it. How do I get rid of that?CSS. Whatever you have applying to regular and submit images probably isn't applying to the button>img. [edit] Maybe your CSS is removing borders on a>imgs only? Edited June 18, 2013 by requinix Quote Link to comment https://forums.phpfreaks.com/topic/279272-how-do-i-add-an-image-to-this-button/#findComment-1436503 Share on other sites More sharing options...
Chrisj Posted June 18, 2013 Author Share Posted June 18, 2013 Thanks for your reply. However, I don't know what you mean by: "CSS. Whatever you have applying to regular and submit images probably isn't applying to the button>img.[edit] Maybe your CSS is removing borders on a>imgs only? Quote Link to comment https://forums.phpfreaks.com/topic/279272-how-do-i-add-an-image-to-this-button/#findComment-1436505 Share on other sites More sharing options...
WebOutGateway Posted August 7, 2014 Share Posted August 7, 2014 (edited) Hi, Chrisj!Maybe what requinix meant was that, in your CSS, you only have the property, which removes the border of the images, inside the <a> tags (a > img). Try applying that property to the images inside the <button> tags (button > img). CSS: button > img { border: none; } I hope this helps. Thank you. Edited August 7, 2014 by WebOutGateway Quote Link to comment https://forums.phpfreaks.com/topic/279272-how-do-i-add-an-image-to-this-button/#findComment-1487070 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.