国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 編程 > JavaScript > 正文

jQuery實(shí)現(xiàn)的form轉(zhuǎn)json經(jīng)典示例

2019-11-19 15:12:24
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

本文實(shí)例講述了jQuery實(shí)現(xiàn)的form轉(zhuǎn)json功能。分享給大家供大家參考,具體如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><script type="application/javascript" src="js/jquery-2.0.3.js"></script><title>無(wú)標(biāo)題文檔</title><script type="application/javascript">$.fn.serializeObject = function(){  var o = {};  var a = this.serializeArray();  $.each(a, function() {    if (o[this.name]) {      if (!o[this.name].push) {        o[this.name] = [o[this.name]];      }      o[this.name].push(this.value || '');    } else {      o[this.name] = this.value || '';    }  });  return o;};function onClik(){    //var data = $("#form1").serializeArray(); //自動(dòng)將form表單封裝成json    //alert(JSON.stringify(data));    var jsonuserinfo = $('#form1').serializeObject();    alert(JSON.stringify(jsonuserinfo));}</script></head><body><form id="form1" name="form1" method="post" action=""> <p>進(jìn)貨人 :  <label for="name"></label>  <input type="text" name="name" id="name" /> </p> <p>性別:  <label for="sex"></label>  <select name="sex" size="1" id="sex">   <option value="1">男</option>   <option value="2">女</option>  </select> </p> <table width="708" border="1">  <tr>   <td width="185">商品名</td>   <td width="205">商品數(shù)量</td>   <td width="296">商品價(jià)格</td>  </tr>  <tr>   <td><label for="pro_name"></label>    <input type="text" name="pro_name" id="pro_name" /></td>   <td><label for="pro_num"></label>    <input type="text" name="pro_num" id="pro_num" /></td>   <td><label for="pro_price"></label>    <input type="text" name="pro_price" id="pro_price" /></td>  </tr>  <tr>   <td><input type="text" name="pro_name2" id="pro_name2" /></td>   <td><input type="text" name="pro_num2" id="pro_num2" /></td>   <td><input type="text" name="pro_price2" id="pro_price2" /></td>  </tr> </table> <p> </p> <input type="button" name="submit" onclick="onClik();" value="提交"/></form></body></html>

代碼效果演示:

PS:關(guān)于json操作,這里再為大家推薦幾款比較實(shí)用的json在線工具供大家參考使用:

在線JSON代碼檢驗(yàn)、檢驗(yàn)、美化、格式化工具:
http://tools.VeVB.COm/code/json

JSON在線格式化工具:
http://tools.VeVB.COm/code/jsonformat

在線XML/JSON互相轉(zhuǎn)換工具:
http://tools.VeVB.COm/code/xmljson

json代碼在線格式化/美化/壓縮/編輯/轉(zhuǎn)換工具:
http://tools.VeVB.COm/code/jsoncodeformat

在線json壓縮/轉(zhuǎn)義工具:
http://tools.VeVB.COm/code/json_yasuo_trans

更多關(guān)于jQuery相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《jQuery form操作技巧匯總》、《jQuery操作json數(shù)據(jù)技巧匯總》、《jQuery常用插件及用法總結(jié)》、《jQuery擴(kuò)展技巧總結(jié)》、《jQuery表格(table)操作技巧匯總》及《jquery選擇器用法總結(jié)

希望本文所述對(duì)大家jQuery程序設(shè)計(jì)有所幫助。

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 静乐县| 兖州市| 遂昌县| 镇平县| 麻栗坡县| 枣阳市| 二手房| 慈利县| 石河子市| 伊吾县| 吉木乃县| 修武县| 宜兴市| 调兵山市| 正安县| 盱眙县| 肇州县| 延吉市| 封丘县| 沈阳市| 宁晋县| 抚州市| 锦屏县| 长子县| 襄垣县| 绿春县| 博罗县| 宁南县| 三都| 沙湾县| 津市市| 交城县| 麻江县| 南溪县| 塔城市| 富平县| 湖南省| 德阳市| 饶河县| 乌鲁木齐县| 内乡县|