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