Eggzorcist Posted August 30, 2012 Share Posted August 30, 2012 trying to catch it so I'm print_r post and nothing is added to $_POST array. I'm wondering what I'm doing wrong? <?php print_r($_POST); ?> <form method="POST" action="<?php echo $_SERVER['PHP_SELF'];?>" onsubmit="return false;" class="asholder"> <small style="float:right">Hidden ID Field: <input type="text" id="userID" value="" style="font-size: 10px; width: 20px;" disabled="disabled" /></small> <input style="width: 200px" type="text" id="personinput" value="" placeholder="Person" /><br /> <input type="radio" name="owes" value="sUser" placeholder="Who Owe's Who?" /> owes me <input type="radio" name="owes" value="mUser" /> I owe them <br /> <input style="width: 200px" type="text" id="amount" value="" placeholder="Amount of..." /><br /> <textarea style="width: 200px; height: 50px;" id="comment" value="" placeholder="Comment"></textarea><br /> <input type="submit" name="submit" value="submit" id="submit" /> </form> </div> any help would be greatly appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/267832-catching-the-submit-button/ Share on other sites More sharing options...
stijn0713 Posted August 30, 2012 Share Posted August 30, 2012 onsubmit="return false;" you should remove that Quote Link to comment https://forums.phpfreaks.com/topic/267832-catching-the-submit-button/#findComment-1374090 Share on other sites More sharing options...
Eggzorcist Posted August 30, 2012 Author Share Posted August 30, 2012 I used that so when the user pressed enter it wouldn't submit. How can I solve that issue then? Quote Link to comment https://forums.phpfreaks.com/topic/267832-catching-the-submit-button/#findComment-1374092 Share on other sites More sharing options...
stijn0713 Posted August 30, 2012 Share Posted August 30, 2012 what's the point of creating a form and submit button if you won't let the user submit anything? Quote Link to comment https://forums.phpfreaks.com/topic/267832-catching-the-submit-button/#findComment-1374094 Share on other sites More sharing options...
Eggzorcist Posted August 30, 2012 Author Share Posted August 30, 2012 I want them to be able to submit using the button. But I'm using an ajax form select which highlights possible users from the database. I want the user to be abl to user the arrow keys to go up and down the list and when they press enter to select that user. I want the submit to work just not by pressing enter button. Quote Link to comment https://forums.phpfreaks.com/topic/267832-catching-the-submit-button/#findComment-1374107 Share on other sites More sharing options...
stijn0713 Posted August 30, 2012 Share Posted August 30, 2012 In that case, you'll need to use javascript and add an event listener for pressing the return key. But i'm not too familiar with that so better let it verified by someone else. Quote Link to comment https://forums.phpfreaks.com/topic/267832-catching-the-submit-button/#findComment-1374112 Share on other sites More sharing options...
SergeiSS Posted August 30, 2012 Share Posted August 30, 2012 It's easy to do 1. onsubmit="return false;" you should remove that - as it was said earlier. 2. Create a function to submit a form. Let it be form_caller(). This function have to set a special JS variable (V) and then call submit() function for a from. 3. Create second function, let's name it submit_check. It checks the state of special variable V and return true if V is set and return false otherwise. 4. Write for the form onsubmit="return submit_check()". 5. It's ready. If you press Enter, submit_check() is called and return false. Form is not submitted. If you call form_caller(), then submit_check() will return true and form will be submitted. I hope that this explanation in clear enough. Quote Link to comment https://forums.phpfreaks.com/topic/267832-catching-the-submit-button/#findComment-1374113 Share on other sites More sharing options...
Christian F. Posted August 31, 2012 Share Posted August 31, 2012 You could just have an event handler listening for the ENTER key when inside the names list, and let it submit the form as normally otherwise. I know I find it quite annoying when standard navigation has been messed with, no matter what the reason. PS: Have you secured PHP_SELF against injection attacks? Quote Link to comment https://forums.phpfreaks.com/topic/267832-catching-the-submit-button/#findComment-1374129 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.