jquery Plugin Easyui Form form submission Instance sharing _jquery

Source: Internet
Author: User

Before using Ajax to pass parameters to controller, and then invoke the server to make changes to the database, today came up with a new method, is the form of submission, so you can omit the Ajax parameters.

When the form is submitted, we can get the values from the controls on the form, and then call the server-side method to make changes to the database. The following screenshot is specific to the business requirements.


One, to achieve the function: from the above form, get the value in the control, and then passed to the background. The following is the form code.
Second, the form code

<div id= "Editwin" class= "Easyui-window" title= "Edit class Information" style= "width:400px; height:auto;top:105px "data-options=" Closed:true,collapsible:false,minimizable:false,maximizable:false "> < Div style= "margin-top:30px; margin-bottom:30px; margin-left:70px; " > <form id= "editform" method= "POST" > <table> <tr> <td> class name:< /td> <td> <input class= "Easyui-validatebox" type= "text" id= "Editclassname" name= "Clas" 
        Sname "data-options=" required:true,validtype:[' maxlength[20] "/> </td> </tr> <tr> <td> <input style= "Display:none" class= "Easyui-textbox" "type=" text "id=" EDITCL 
          Assid "Name=" ClassID "data-options=" Required:true "/> </td> </tr> <tr> <td> Affiliated institutions:</td> <td> <input id= "Editorganizationid" class= "easyui-com" BobOx "name=" OrganizationName1 "data-options=" Required:true "/> </tr> <tr> &L T;td> grade:</td> <td> <input id= "Editgradeid" class= "Easyui-combobox" name= "Gradena" 
          Me "data-options=" Required:true "/> </tr> <tr> <td> remarks:</td> <td> <textarea class= "Easyui-validatebox" id= "Noteid" name= "note" validtype:[' MAXLENGTH[50]&G t;</textarea> </tr> </table> <div style= "margin-top:20px;" > <a class= "Easyui-linkbutton" data-options= "iconcls: ' Icon-ok '" style= "margin-left:10px" onclick= "Editsub Mitform () "> OK </a> <a class=" Easyui-linkbutton "data-options=" iconcls: ' Icon-cancel ' "style=" Margin-lef 
 t:60px "onclick=" Editclearform () "> Cancellation </a> </div> </form> </div> </div>

Three, form submission code  

function Editsubmitform () {$ (' #EditForm '). Form (' Submit ', {URL: "/basicclass/modifyclassinfo", Onsubmit:function () {//The callback function before submitting the form is var isValid = $ (this). Form (' validate ');//Verify that the values of some controls in the form are filled in correctly, such as some text boxes The content in must be the number if (!isvalid) {} return isValid; If validation does not pass, return false to terminate form submission}, success:function (data) {//form submitted after successful callback function, inside parameter data is we call/BASICCLASS/MODIFYCL 
          The return value of the Assinfo method. 
              if (Data > 0) {$.messager.show ({title: ' Hint Message ', msg: ' Submit successfully ', ShowType: ' Show ', timeout:1000, style: {right: ', Bott 
            Om: '}});  $ (' #dg '). DataGrid (' reload '); Reload the current page data $ (' #Editwin '). Window (' close '); Close Window} else {$.messager.alert (' hint info ', ' submit failed, please contact admin! 
        ', ' warning '); 
} 
        } 
      }); 
 }

Four, backstage controller obtains the data in the form

Get the name of the class you want to add 
       string ClassName = request.form["ClassName"]; 
       Get class ID 
       Guid ClassID = new Guid (request.params["ClassID"]); 
       String classnote = request.form["Note"]; 

Beginner practice, it feels more useful than Ajax, because the Ajax through the parameters of the name of all the names must be written in, when a form is submitted, the contents of the form are passed by default, so that whatever data we have in the form can be retrieved in the background, and of course, the data is bound in advance, Or we've filled it in before.

The above is the entire content of this article, I hope to learn from the jquery program to help.

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.