Use js to control the submission of forms without names. js forms
In the BS front-end design, it is very convenient to submit forms in some places.
However, there are many forms in the middle.
Form creation:
1. Use <form> </form> to create
2. directly set the form attributes to create a form without a name
1. For forms with names, you can directly write js events for submission.
// Set the form submission method $ ('# importMethod '). form ({url: "/QuestionType/FuzzyQueryQuestionType", onSubmit: function () {// perform form Verification // if false is returned to prevent submission}, success: function (data) {// var jsondata = JSON. parse (data); // must be converted to a json object; otherwise, an exception occurs! Rows is undefined var jsondata = eval (data); $ ('# dgo '). datagrid ("loadData", jsondata); // $ ('# dgo '). datagrid ("reload") ;}}); // submit the form $ ('# importMethod '). submit ();
When submitting a form using js, you can perform many settings on submission.
2. For the second method, the form does not write the name attribute. Therefore, JavaScript cannot be used for operations.
In this way, an attribute is usually added to a button in the form. type = "submit" click this button to submit the form.
In this way, only one Button can be submitted. For other buttons, such buttons are not suitable.
To solve the existence of such a button, you can try to transfer the button event:
Create another button and use js to control the button events. (Hide the button)
@ * Button in the form to submit the form * @ <input id = "btnImport" type = "submit" value = "import" style = "display: none; width: 60px; height: 28px; margin-left: 15% "/> @ * use the Easyui button instead of * @ <a id =" aImport "class =" easyui-linkbutton "onclick =" CallImport (); "style =" margin-left: 15% "> <span class =" l-btn-text "> Import </span> </a> <script> // indirectly call the import method function CallImport () {// alert ("dddd"); document. getElementById ('btnimport '). click () ;}</script>
:
It is a simple patchwork to control forms without names.
There are many places to design a style for the front-end. No matter how you set it, you cannot see the effect. Add a bit of seemingly redundant code. Occasionally, some problems are solved.