Pop-up box, add traveler, append Submit method, H5 check OK and then call Ajax commit to Controller

Source: Internet
Author: User

01 passing parameters, showing or hiding pop-up boxes


/*start Show and hide Masks */
function Controlshade (date) {
if (date = = ' s ') {
$ (". Mask"). Show ();
$ (". Maskbox"). Stop (). Animate ({"Margin-top": + + "px"},300);
}else if (date = = ' h ') {
$ (". Maskbox"). Stop (). Animate ({"Margin-top": -500+ "px"},300,function () {
$ (". Mask"). Hide ();
});
}
}
/*end Show and hide Masks */

02 Gets the form form, appends the on method, passes the submit parameter, and the method when the form form executes the submit. Method to execute the second argument

<form id= "Addmester" action= "";
<ul>
<li>
<span> name: </span>
< Input type= "text" name= "Contact_Name" id= "Contact_Name" class= "InputStyle2 membername" maxlength= "required=" Required "
</li>
<li>
<span> Mobile: </span>
<input type=" Tel "name=" Contact_mobile "id=" Contact_mobile "class=" InputStyle2 "required=" Required "pattern=" (^1[3|4|5|7|8][0-9]{9}$) " Title= "Please enter the correct mobile phone number!
</li>
<li>
<span> Document type: </SPAN>
<select name= "Idtype" id= "Idtype" >
<option value= "id" > Identity card </option>
<option value= "Passport" > Passport </option>
<option Value= "Officer Card" > Officer card </option>
</select>
</li>
<li>
<span> ID: </span
<!--<input type= "text" id= "credentials" class= "InputStyle2" required= "required" pattern= "" title= " Please enter the correct ID number according to the type of document "
</li>
</ul>

<div class= "Choosebtns" >
<input type= "Submit" class= "Sureadd" onclick= "value=" OK ">
<input type= "button" class= "Canceladd" onclick= "Controlshade (' h ')" Value= "Cancel" >
</div>
</form>

03

function Initaddcontectform () {
var $forms =$ ("#addMester");

$forms. On (' Submit ', function (EV) {
Ev.preventdefault ();
var name=$ ("#contact_name"). Val ();
var mobile=$ ("#contact_mobile"). Val ();
var idcardtype=$ ("#idType"). Find ("option:selected"). Val ();
var idcard=$ ("#credentials"). Val ();


$.ajax ({
URL: "/apply/addcontacts",
Type: ' POST ',
data:{' contact_name ': Name, ' Contact_mobile ': Mobile, ' contact_identication_type ': Idcardtype, ' contact_identication _number ': Idcard},
DataType: ' JSON ',
Success:function (d) {
var html= "<label style= ' padding:0 5px "><input type= ' checkbox ' name= ' apply_members[] ' value= '" +d["contact_id"]+ "' > ' +d[' contact_name ']+ ' </label> ";
$ (". Addmmber"). Append (HTML);
Ichecks (); return;
},error:function () {
Alert (' Error ');
}

});


Controlshade (' h ');
});
}

04 the page has been loaded. Start method, add an on method to form form,

<script>
Initaddcontectform ();
</script>

Error

Pop-up box, add traveler, append Submit method, H5 check OK and then call Ajax commit to Controller

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.