phpretard Posted October 19, 2008 Share Posted October 19, 2008 I have form using an image as a submit button. It won't submit when I press enter...only if I click the button. This may not be a PHP help but I figured I throw it out here and see if anyone could point me in the right direction. I've been all over Google and the only reference I could find was standard type='submit'. ...and yes if (isset(I_Know_y)){ blah Quote Link to comment Share on other sites More sharing options...
grim1208 Posted October 19, 2008 Share Posted October 19, 2008 post the code you are using for the page please Quote Link to comment Share on other sites More sharing options...
phpretard Posted October 19, 2008 Author Share Posted October 19, 2008 Thanks for the quick response. // FORM PAGE <form action='SUBMITPAGE' method=post> <input type='text' name='PrimSearch' /> <type='image' src='/images/search.gif' name='MainSearch' /></td> </form> // SUBMIT PAGE if (isset($_POST['MainSearch_y'])){ echo "Enter Button Won't Work"; } Quote Link to comment Share on other sites More sharing options...
Andy-H Posted October 19, 2008 Share Posted October 19, 2008 I had the same problem but couldn't figure it out either. BTW that should be <input type='image' src='/images/search.gif' name='MainSearch' /> Quote Link to comment Share on other sites More sharing options...
grim1208 Posted October 19, 2008 Share Posted October 19, 2008 Is this the actual code you are using? 1) for your button, you have <type='image' src='/images/search.gif' name='MainSearch' /> it should have input before type to look like this <input type='image' src='/images/search.gif' name='MainSearch' /> 2)Submitpage, doesn't have an extension on it, such as php, html I am sure you just threw that together for example, but def. make sure you are still using <input not just <type I have tested w/ <input in front in Firefox, and works when you hit enter on the button Quote Link to comment Share on other sites More sharing options...
Andy-H Posted October 19, 2008 Share Posted October 19, 2008 <style> input.Image { width: width_px; height: height_px; border: 0px; background-image: url('/images/search.gif') center center; } </style> <input type='submit' value="" class="Image" /> ?? Quote Link to comment Share on other sites More sharing options...
phpretard Posted October 19, 2008 Author Share Posted October 19, 2008 Andy-H: I don't get it? Yes I am using <input... There was a lot of useless info to post (my bad). I should mention it works great when the image is "clicked". It does work in firefox but...I wish everyone used firefox. Any work around for IE? Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted October 19, 2008 Share Posted October 19, 2008 I can at least tell you why - for the enter key to submit a form, the current "focus" must be the submit button. How you can solve this can probably be found through searching the Internet. Quote Link to comment Share on other sites More sharing options...
phpretard Posted October 19, 2008 Author Share Posted October 19, 2008 I have been searching the internet for 2 hours and nothing refers to an image as the submit obj. So should I $rephrase the question? if ($rephrase=='Yes'){$question="How can I force the focus?";} else {echo"beat it with this question!";} Quote Link to comment Share on other sites More sharing options...
phpretard Posted October 19, 2008 Author Share Posted October 19, 2008 I have come up with this... onKeyDown=\"if(event.which==13||event.keyCode==13){alert('Please Click The Search Button')}\" I was hope for a real solution. Quote Link to comment Share on other sites More sharing options...
AndyB Posted October 19, 2008 Share Posted October 19, 2008 I have been searching the internet for 2 hours and nothing refers to an image as the submit obj. So should I $rephrase the question? It's got absolutely nothing to do with the form of the 'submit' thing. I searched the internet for 2 seconds for "submit form on enter javascript". http://www.google.ca/search?q=submit+form+on+enter+javascript&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-GB:official&client=firefox-a Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted October 19, 2008 Share Posted October 19, 2008 It turns out the browser action changes if there is a single text field or if there are more than one. If you add a second text field to your test code, it will probably stop working in the browser that it seems to be working in now. Here is a link I found (among the thousands that a search on how to do this common task will find) that shows how to force the enter key to submit a form - http://jennifermadden.com/javascript/stringEnterKeyDetector.html Quote Link to comment Share on other sites More sharing options...
phpretard Posted October 19, 2008 Author Share Posted October 19, 2008 OH Well... 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.