日期:2014-05-17  浏览次数:20555 次

求类似phpmyadmin的复选框功能,带修改功能
从数据库中把对应的值列出来,前面加复选框,可以单选或者多选。选择修改按钮针对选中列进行批量修改,类似phpmyadmin的复选框功能。请教大概思路,如何实现此功能?

------解决方案--------------------
ajax 读数据 循环输出数据 数据前面加个<input ...其他的不都是js的部分了么
------解决方案--------------------
取值的时候
while($row=mysql_fetch_array($res)){
echo "<input type=\"checkbox\" value=".$i.">";
echo $row['myClo1']." ".$row['myClo2'];
}//这样数据就加载完成了,以下是操作
用JS就行了,但若你用jquery的话,更方便
$("#alter").click(function(){
$("input[type=checkbox]").each(function(){
if($(this).attr("checked"))
{
$(this).removeAttr("checked");//do sth here

})
})
------解决方案--------------------
PHP code

<?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>

------解决方案--------------------
问题应该出在其他地方
HTML code
<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