form-submit

How to prevent multiple inserts when submitting a form in PHP?

半世苍凉 提交于 2019-11-26 05:21:53
问题 Sometimes the user may press Enter twice, and the post is inserted twice. Is there a solution to prevent this other than check if there is already a post with the same title and content ? 回答1: There are several solutions to this problem: Use Javascript to disable the form's submit button when it is posted. Downside to this is that this is ABSOLUTELY not a foolproof way. It's very easy to submit forms without actually clicking the button, and this would also not work for users with JavaScript

Submit form with Enter key without submit button? [duplicate]

落花浮王杯 提交于 2019-11-26 05:16:55
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: HTML: Submitting a form by pressing enter without a submit button How can I submit a form with just the Enter key on a text input field, without having to add a submit button? I remember this worked in the past, but I tested it now and the form doesn\'t get submitted unless there\'s a submit-type input field inside it. 回答1: $("input").keypress(function(event) { if (event.which == 13) { event.preventDefault(); $(

How do I create multiple submit buttons for the same form in Rails?

二次信任 提交于 2019-11-26 03:51:49
问题 I need to have multiple submit buttons. I have a form which creates an instance of Contact_Call. One button creates it as normal. The other button creates it but needs to have a different :attribute value from the default, and it also needs to set the attribute on a different, but related model used in the controller. How do I do that? I can\'t change the route, so is there a way to send a different variable that gets picked up by [:params]? And if I do then, what do I do in the controller,

Values of disabled inputs will not be submitted

对着背影说爱祢 提交于 2019-11-26 03:15:08
问题 This is what I found by Firebug in Firefox. Is it the same in other browsers? If so, what\'s the reason for this? 回答1: Yes, all browsers should not submit the disabled inputs, as they are read-only. More information (section 17.12.1) Attribute definitions disabled [CI] When set for a form control, this Boolean attribute disables the control for user input. When set, the disabled attribute has the following effects on an element: Disabled controls do not receive focus. Disabled controls are

Submitting HTML form using Jquery AJAX

耗尽温柔 提交于 2019-11-26 03:14:05
问题 Im trying to submit a HTML form using AJAX using this example. My HTML code: <form id=\"formoid\" action=\"studentFormInsert.php\" title=\"\" method=\"post\"> <div> <label class=\"title\">First Name</label> <input type=\"text\" id=\"name\" name=\"name\" > </div> <div> <label class=\"title\">Name</label> <input type=\"text\" id=\"name2\" name=\"name2\" > </div> <div> <input type=\"submit\" id=\"submitButton\" name=\"submitButton\" value=\"Submit\"> </div> </form> My script: <script type=\"text

What&#39;s wrong with using $_REQUEST[]?

女生的网名这么多〃 提交于 2019-11-26 03:13:27
问题 I\'ve seen a number of posts on here saying not to use the $_REQUEST variable. I usually don\'t, but sometimes it\'s convenient. What\'s wrong with it? 回答1: There's absolutely nothing wrong with taking input from both $_GET and $_POST in a combined way. In fact that's what you almost always want to do: for a plain idempotent request usually submitted via GET, there's the possibility the amount of data you want won't fit in a URL so it has be mutated to a POST request instead as a practical

Multiple submit buttons in an HTML form

余生颓废 提交于 2019-11-26 02:50:45
问题 Let\'s say you create a wizard in an HTML form. One button goes back, and one goes forward. Since the back button appears first in the markup when you press Enter , it will use that button to submit the form. Example: <form> <!-- Put your cursor in this field and press Enter --> <input type=\"text\" name=\"field1\" /> <!-- This is the button that will submit --> <input type=\"submit\" name=\"prev\" value=\"Previous Page\" /> <!-- But this is the button that I WANT to submit --> <input type=\

jQuery serializeArray doesn&#39;t include the submit button that was clicked

痞子三分冷 提交于 2019-11-26 02:37:55
问题 I have a form that has two buttons. One for saving a record and the other for cancelling the save procedure. I am using the rails.js (a common AJAX/jQuery plug-in for those of you not in the know) javascript file that works with jQuery for unobtrusive javascript/ajax calls. When I send the form data over ajax, I want the name and value of the button I clicked to be submitted with the rest of the data so that I can make a decision on what to do based on which button was clicked. The method in

jquery disable form submit on enter

瘦欲@ 提交于 2019-11-26 01:46:37
问题 I have the following javascript in my page which does not seem to be working. $(\'form\').bind(\"keypress\", function(e) { if (e.keyCode == 13) { e.preventDefault(); return false; } }); I\'d like to disable submitting the form on enter, or better yet, to call my ajax form submit. Either solution is acceptable but the code I\'m including above does not prevent the form from submitting. 回答1: If keyCode is not caught, catch which : $('#formid').on('keyup keypress', function(e) { var keyCode = e

How do you handle multiple submit buttons in ASP.NET MVC Framework?

独自空忆成欢 提交于 2019-11-25 22:17:51
问题 Is there some easy way to handle multiple submit buttons from the same form? Example: <% Html.BeginForm(\"MyAction\", \"MyController\", FormMethod.Post); %> <input type=\"submit\" value=\"Send\" /> <input type=\"submit\" value=\"Cancel\" /> <% Html.EndForm(); %> Any idea how to do this in ASP.NET Framework Beta? All examples I\'ve googled for have single buttons in them. 回答1: Here is a mostly clean attribute-based solution to the multiple submit button issue based heavily on the post and