leachus2002 Posted December 16, 2010 Share Posted December 16, 2010 Hi Everyone, I am a great fan of the 'isset' function, which I use alot when submitting forms, but not wanting to navigate away from the page. Normally I just use a form with a submit button with a name, for example: <input type='submit' name='updatetable' value='Go!'/> and then use the following: <?php if (isset ($_POST['updatetable'])) { do this stuff... } ?> But I want to start to use images as submit buttons, so when you click on them, you are able to submit the underlying data. Is there a way to do this using the isset function? Because effectively, the image, which would submit using javascript, wont have a name. Any ideas appreciated Many Thanks Matt Quote Link to comment Share on other sites More sharing options...
solon Posted December 16, 2010 Share Posted December 16, 2010 Hey leachus2002. Do you mean that you want to submit the image (that will be used as a button) or a value that will change according to the image clicked? Quote Link to comment Share on other sites More sharing options...
johnny86 Posted December 16, 2010 Share Posted December 16, 2010 Use <input type="submit" src="path/to/your/image.jpg" name="updatetable"> That will show your image as a submit button and is valid HTML. Quote Link to comment Share on other sites More sharing options...
leachus2002 Posted December 16, 2010 Author Share Posted December 16, 2010 Hi Johnny86, That's the right idea, however when I use that code, I just get a submit button. To confirm, code is: <input type='submit' src='../images/tag_blue.png' name='submitform'/> Any ideas? Thanks Matt Quote Link to comment Share on other sites More sharing options...
johnny86 Posted December 16, 2010 Share Posted December 16, 2010 I don't really understand what you mean by "I just get a submit button"? You should only get the submit button but as an image. Then you can use your normal way of <?php if (isset ($_POST['updatetable'])) { do this stuff... } ?> Quote Link to comment Share on other sites More sharing options...
solon Posted December 16, 2010 Share Posted December 16, 2010 use css style to change how your button looks: <input type="submit" name="updatetable" value="" style="background-image:url(your_image.jpg); width:50px; height:50px;" /> and then handle it like you have it: <?php if (isset ($_POST['updatetable'])) { do this stuff... } ?> Quote Link to comment Share on other sites More sharing options...
leachus2002 Posted December 16, 2010 Author Share Posted December 16, 2010 Solon, Still no luck I am afraid - i copied and pasted your code and all I get is a grey rectangular box - basically a submit button without any text inside Any other ideas? Thanks Matt Quote Link to comment Share on other sites More sharing options...
johnny86 Posted December 16, 2010 Share Posted December 16, 2010 If you dont have your button text merged into your button image you just need to specify value for the button: <input type="submit" src="image.jpg" value="My button text"> You can also use CSS to load the image and to enhance your button text as solon said. Quote Link to comment Share on other sites More sharing options...
solon Posted December 16, 2010 Share Posted December 16, 2010 Could you post the exact code you are using? Quote Link to comment Share on other sites More sharing options...
leachus2002 Posted December 16, 2010 Author Share Posted December 16, 2010 I literally cut and paste your code that you wrote in to a blank web page. Cheers Matt Quote Link to comment Share on other sites More sharing options...
solon Posted December 16, 2010 Share Posted December 16, 2010 ok then... did you change the style="background-image:url(your_image.jpg); to an actual image? Quote Link to comment Share on other sites More sharing options...
leachus2002 Posted December 16, 2010 Author Share Posted December 16, 2010 Hi Solon, Yep sure did - still nothing. Thanks Matt Quote Link to comment Share on other sites More sharing options...
solon Posted December 16, 2010 Share Posted December 16, 2010 Well you must be doing something wrong... i tested it and it works. So please post your code here so we can see if there is anything wrong Quote Link to comment Share on other sites More sharing options...
leachus2002 Posted December 16, 2010 Author Share Posted December 16, 2010 Solon, Here is the code: <head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> <title>Untitled 1</title> </head> <body> <input type="submit" name="updatetable" value="" style="background-image:url(flexierror.jpg); width:50px; height:50px;" /> </body> </html> As you can see, just cut and pasted. Further to these comments, I have tried Firefox and its ok (ish) - however IE still isnt. Cheers Matt Quote Link to comment Share on other sites More sharing options...
leachus2002 Posted December 16, 2010 Author Share Posted December 16, 2010 Got it working now Used the following: margin: 0; padding: 0; border: 0; background: transparent url(SearchGoogle.gif) no-repeat center top; Cheers Matt Quote Link to comment Share on other sites More sharing options...
ADynaMic Posted December 16, 2010 Share Posted December 16, 2010 Hi leachus2002, I got the same problem, it was to use an image exactly as an submit button. Following solved my problem. Give it a try... <?php if (isset($_POST['picButton'])){ /* Hit the goal using the 'value' parameter */ } ?> It was as usual. Down here the input type is set as 'image' instead of 'submit'. It'll do the trick.. <input type="image" name="picButton" value="first" src="/images/arrow.jpg"/> May have to adjust width height etc. using styles. 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.