求类似phpmyadmin的复选框功能,带修改功能
从数据库中把对应的值列出来,前面加复选框,可以单选或者多选。选择修改按钮针对选中列进行批量修改,类似phpmyadmin的复选框功能。请教大概思路,如何实现此功能?
------解决方案--------------------
ajax 读数据 循环输出数据 数据前面加个------解决方案--------------------
取值的时候
while($row=mysql_fetch_array($res)){
echo "";
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 #test19.php
if(isset($_POST['save'])){
print_r($_POST);
#测试数据
#Array ( [int] => Array ( [0] => 1 ) [name1] => Lucy [name2] => woman [save] => save )
}
?>
<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><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>
<br><font color="#e78608">------解决方案--------------------</font><br>
问题应该出在其他地方
<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']").removeAttr("checked");//取消全选
})
$("#btn3").click(function(){//输出选中的值
var str="";
$("[name='checkbox'][checked]").each(function(){
str+=$(this).val()+"\r\n";
//alert($(this).val());
})
alert(str);
})
})
-->
</script><div style="background: #eee;">
<form name="form1" method="post" action="">
<input align="center" type="button" id="btn1" value="全选"><input align="center" type="button" id="btn2" value="取消全选"><input type="button" id="btn3" value="获得选中的所有值"><br><br><?php for($i=0; $i<10; $i++)
echo "<input type=checkbox name=checkbox value=$i>";
<div class="clear"></div>
</form>
</div>
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
C++高性能并发应用_C++如何开发性能关键应用
Java AI集成Deep Java Library_Java怎么集成AI模型部署
Golang后端API开发_Golang如何高效开发后端和API
Python异步并发改进_Python异步编程有哪些新改进
C++系统编程内存管理_C++系统编程怎么与Rust竞争内存安全
Java GraalVM原生镜像构建_Java怎么用GraalVM构建高效原生镜像
Python FastAPI异步API开发_Python怎么用FastAPI构建异步API
C++现代C++20/23/26特性_现代C++有哪些新标准特性如modules和coroutines
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号