日期:2014-05-17 浏览次数:20606 次
<?php #test19.php if(isset($_POST['save'])){ print_r($_POST); #测试数据 #Array ( [int] => Array ( [0] => 1 ) [name1] => Lucy [name2] => woman [save] => save ) } ?> <!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" /> <title>checkbox-edit</title> <script language="javascript" type="text/javascript" src="jquery_1.4.2.js"></script> </head> <body> <script> $(function(){ $("input[name='edit']").click(function(){ $("input[name^='int']").each(function(){ if($(this).attr("checked")){ var objtd1 = $(this).parent().next("td"); var objtd2 = $(this).parent().next("td").next("td"); //alert("td1-->>"+objtd1+"\ntd2-->>"+objtd2); objtd1.html("<input type='text' name='name1' value='"+objtd1.text()+"' />"); objtd2.html("<input type='text' name='name2' value='"+objtd2.text()+"' />"); } }); }); }); </script> <div> <form name="editdata" action="test19.php" method="post"> <table border="" cellpadding="0" cellspacing="0"> <tr> <td></td><td>Name</td><td>Sex</td> </tr> <tr> <td><input type="checkbox" name="int[]" value="1" /></td> <td>TOM</td> <td>man</td> </tr> <tr> <td><input type="checkbox" name="int[]" value="2" /></td> <td>Lily</td> <td>woman</td> </tr> </table> <input type="button" name="edit" value="edit" /> <input type="submit" name="save" value="save" /> </form> </div> </body> </html>
------解决方案--------------------
问题应该出在其他地方
<script type='text/javascript' src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> <script language="JavaScript"> <!-- $("document").ready(function(){ $("#btn1").click(function(){ $("[name='checkbox']").attr("checked",'true');//全选 }) $("#btn2").click(function(){ $("[name='checkbox