Home > Backend Development > PHP Tutorial > ajax 批量提交

ajax 批量提交

WBOY
Release: 2016-06-23 13:57:21
Original
1071 people have browsed it



每一行是一条订单  现在给订单加备注  不知道怎么能实现批量提交  求思路


回复讨论(解决方案)

把他当成表单不是一样的吗,和批量删除一样
另外可以在备注文本框加个onchange事件,修改后自动AJAX提交

client.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head>  <meta http-equiv="content-type" content="text/html; charset=utf-8">  <title> client post</title>  <script src="//code.jquery.com/jquery-1.11.0.min.js"></script> </head> <body>  <script type="text/javascript">  function fsubmit(){		var bzArray = '';		$("input[name='bz[]']").each(function(){			bzArray+= "&bz[" + $(this).attr('oid') + "]="+$(this).val(); 		});		$.post("server.php", bzArray,function(ret){			alert(ret);		});  }  </script>  <input type="button" value="批量提交" onclick="fsubmit()">  <table>   <tr>     <td>编号</td>     <td>名称</td>     <td>价格</td>     <td>备注</td>     <td>时间</td>   </tr>   <tr>     <td>5121653</td>     <td>orer name 1</td>     <td>20</td>     <td><input type="text" oid="5121653" name="bz[]"></td>     <td>1970-01-01 00:00:20</td>   </tr>   <tr>     <td>5121654</td>     <td>orer name 2</td>     <td>30</td>     <td><input type="text" oid="5121654" name="bz[]"></td>     <td>1970-01-01 00:00:30</td>   </tr>   <tr>     <td>5121655</td>     <td>orer name 3</td>     <td>50</td>     <td><input type="text" oid="5121655" name="bz[]"></td>     <td>1970-01-01 00:00:50</td>   </tr>     <tr>     <td>5121657</td>     <td>orer name 4</td>     <td>40</td>     <td><input type="text" oid="5121657" name="bz[]"></td>     <td>1970-01-01 00:00:40</td>   </tr>    </table>  </body></html>
Copy after login
Copy after login


server.php 获取提交的备注与order id
<?php$bz = $_POST['bz'];foreach($bz as $key=>$val){    echo $key.'='.$val."\r\n";}?>
Copy after login
Copy after login

client.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head>  <meta http-equiv="content-type" content="text/html; charset=utf-8">  <title> client post</title>  <script src="//code.jquery.com/jquery-1.11.0.min.js"></script> </head> <body>  <script type="text/javascript">  function fsubmit(){		var bzArray = '';		$("input[name='bz[]']").each(function(){			bzArray+= "&bz[" + $(this).attr('oid') + "]="+$(this).val(); 		});		$.post("server.php", bzArray,function(ret){			alert(ret);		});  }  </script>  <input type="button" value="批量提交" onclick="fsubmit()">  <table>   <tr>     <td>编号</td>     <td>名称</td>     <td>价格</td>     <td>备注</td>     <td>时间</td>   </tr>   <tr>     <td>5121653</td>     <td>orer name 1</td>     <td>20</td>     <td><input type="text" oid="5121653" name="bz[]"></td>     <td>1970-01-01 00:00:20</td>   </tr>   <tr>     <td>5121654</td>     <td>orer name 2</td>     <td>30</td>     <td><input type="text" oid="5121654" name="bz[]"></td>     <td>1970-01-01 00:00:30</td>   </tr>   <tr>     <td>5121655</td>     <td>orer name 3</td>     <td>50</td>     <td><input type="text" oid="5121655" name="bz[]"></td>     <td>1970-01-01 00:00:50</td>   </tr>     <tr>     <td>5121657</td>     <td>orer name 4</td>     <td>40</td>     <td><input type="text" oid="5121657" name="bz[]"></td>     <td>1970-01-01 00:00:40</td>   </tr>    </table>  </body></html>
Copy after login
Copy after login


server.php 获取提交的备注与order id
<?php$bz = $_POST['bz'];foreach($bz as $key=>$val){    echo $key.'='.$val."\r\n";}?>
Copy after login
Copy after login



 辛苦了 非常感谢
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template