TeddyKiller Posted March 12, 2010 Share Posted March 12, 2010 How can I submit a form using the enter key on the keyboard? Quote Link to comment https://forums.phpfreaks.com/topic/195065-submit-form-on-enter-button/ Share on other sites More sharing options...
Tazerenix Posted March 12, 2010 Share Posted March 12, 2010 1: Fill in Form 2: Press enter Quote Link to comment https://forums.phpfreaks.com/topic/195065-submit-form-on-enter-button/#findComment-1025403 Share on other sites More sharing options...
TeddyKiller Posted March 12, 2010 Author Share Posted March 12, 2010 Considering the enter key only does new lines and doesn't submit the form. Quite impossible. Oh and I just noticed, this is the wrong place for this post >.< Sorry Quote Link to comment https://forums.phpfreaks.com/topic/195065-submit-form-on-enter-button/#findComment-1025410 Share on other sites More sharing options...
trq Posted March 12, 2010 Share Posted March 12, 2010 Considering the enter key only does new lines and doesn't submit the form. Quite impossible. You'll need to tab out of whatever box your typing in obviously. Quote Link to comment https://forums.phpfreaks.com/topic/195065-submit-form-on-enter-button/#findComment-1025411 Share on other sites More sharing options...
cags Posted March 12, 2010 Share Posted March 12, 2010 Attach a JavaScript keydown event, if the key is enter submit the form. This isn't possible with PHP as it is client side. Quote Link to comment https://forums.phpfreaks.com/topic/195065-submit-form-on-enter-button/#findComment-1025412 Share on other sites More sharing options...
Tazerenix Posted March 12, 2010 Share Posted March 12, 2010 only if your typeing in a textarea Also: PHP doesnt actually have forms. Try htmlfreaks.com Quote Link to comment https://forums.phpfreaks.com/topic/195065-submit-form-on-enter-button/#findComment-1025413 Share on other sites More sharing options...
TeddyKiller Posted March 12, 2010 Author Share Posted March 12, 2010 Considering the enter key only does new lines and doesn't submit the form. Quite impossible. You'll need to tab out of whatever box your typing in obviously. Well yeah, but how would you do it just by clicking enter? I've tried all methods and they dont actually work. Attach a JavaScript keydown event, if the key is enter submit the form. This isn't possible with PHP as it is client side. Again, I've tried many methods.. this is what I've got at the moment. <script type="text/javascript"> <!-- function submitenter(myfield,e) { var keycode; if (window.event) keycode = window.event.keyCode; else if (e) keycode = e.which; else return true; if (keycode == 13) { document.form.submit(); return false; } else return true; } //--> </script> <form> <textarea name="nonaction" cols="50" rows="3" wrap="virtual" id="rptext" class="textarea" onKeyPress="return submitenter(this,event)"></textarea> <input type=submit value=SUBMIT> </form> Thoguh it doesn't work, though yes. It is a text area. Quote Link to comment https://forums.phpfreaks.com/topic/195065-submit-form-on-enter-button/#findComment-1025415 Share on other sites More sharing options...
TeddyKiller Posted March 12, 2010 Author Share Posted March 12, 2010 PHP doesnt actually have forms. Try htmlfreaks.com Bad link Quote Link to comment https://forums.phpfreaks.com/topic/195065-submit-form-on-enter-button/#findComment-1025417 Share on other sites More sharing options...
trq Posted March 13, 2010 Share Posted March 13, 2010 PHP doesnt actually have forms. Try htmlfreaks.com Bad link I think Tazerenix was just hinting that your question was in the wrong board. Quote Link to comment https://forums.phpfreaks.com/topic/195065-submit-form-on-enter-button/#findComment-1025424 Share on other sites More sharing options...
Tazerenix Posted March 13, 2010 Share Posted March 13, 2010 spot on Quote Link to comment https://forums.phpfreaks.com/topic/195065-submit-form-on-enter-button/#findComment-1025426 Share on other sites More sharing options...
TeddyKiller Posted March 13, 2010 Author Share Posted March 13, 2010 Considering the enter key only does new lines and doesn't submit the form. Quite impossible. Oh and I just noticed, this is the wrong place for this post >.< Sorry I realised, it's put in that post >.< Should I repost? Quote Link to comment https://forums.phpfreaks.com/topic/195065-submit-form-on-enter-button/#findComment-1025429 Share on other sites More sharing options...
trq Posted March 13, 2010 Share Posted March 13, 2010 Considering the enter key only does new lines and doesn't submit the form. Quite impossible. Oh and I just noticed, this is the wrong place for this post >.< Sorry I realised, it's put in that post >.< Should I repost? No, double posting is NOT allowed. Your thread has been moved (twice) and is now in the correct location. Quote Link to comment https://forums.phpfreaks.com/topic/195065-submit-form-on-enter-button/#findComment-1025430 Share on other sites More sharing options...
TeddyKiller Posted March 13, 2010 Author Share Posted March 13, 2010 Oh. Ok. I am sorry. Can you help me with why it doesn't work with the code up there ^ Quote Link to comment https://forums.phpfreaks.com/topic/195065-submit-form-on-enter-button/#findComment-1025433 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.