Jump to content

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/267832-catching-the-submit-button/
Share on other sites

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.

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.

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?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.