Use js to control the submission of forms without names. js forms

Source: Internet
Author: User

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.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.