Functions that are used with jquery Serializearray (), primarily to facilitate the submission of forms _jquery

Source: Internet
Author: User
The. Serializearray () serializes the table element (similar to the '. Serialize () ' method) to return the JSON data structure. (Excerpt from the jquery document).
There is one of the following form windows, code:
Copy Code code as follows:

<form action= "" method= "Post" id= "TF" >
<table width= "100%" cellspacing= "0" cellpadding= "0" border= "0" >
<tr>
<th> name:</th>
<td>
<input type= "text" id= "txtUserName" name= "UserName"/>
</td>
<th> Contact Mobile:</th>
<td>
<input type= "text" name= "Mobile" id= "Txtmobile" maxlength= "one"/>
</td>
</tr>
<tr>
<TD style= "Text-align:center" colspan= "2" >
<input type= "button" value= "submitted" style= "padding-top:3px" name= "Butsubmit" id= "" Butsubmit "/>
</td>
</tr>
</table>
</form>

JavaScript code processing forms:
Copy Code code as follows:

<script>
$ (function () {
$ ("#butsubmit"). Click (function () {
var data = Convertarray ($ ("#tf"). Serializearray ());
$.post (URL, data, function (d) {}, "JSON");
});
})
function Convertarray (o) {//The main recommendation is to do this. It turns jquery's serialized value into Name:value form.
var v = {};
for (var i in O) {
if (typeof (V[o[i].name]) = = ' undefined ') v[o[i].name] = O[i].value;
else V[o[i].name] + + o[i].value;
}
return v;
}
</script>

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.