Home Backend Development PHP Tutorial 求相仿phpmyadmin的复选框功能,带修改功能

求相仿phpmyadmin的复选框功能,带修改功能

Jun 13, 2016 pm 01:23 PM
gt input lt name quot

求类似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 code

<?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>
问题应该出在其他地方
Copy after login
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']").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>
Copy after login
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What are the differences between Huawei GT3 Pro and GT4? What are the differences between Huawei GT3 Pro and GT4? Dec 29, 2023 pm 02:27 PM

Many users will choose the Huawei brand when choosing smart watches. Among them, Huawei GT3pro and GT4 are very popular choices. Many users are curious about the difference between Huawei GT3pro and GT4. Let’s introduce the two to you. . What are the differences between Huawei GT3pro and GT4? 1. Appearance GT4: 46mm and 41mm, the material is glass mirror + stainless steel body + high-resolution fiber back shell. GT3pro: 46.6mm and 42.9mm, the material is sapphire glass + titanium body/ceramic body + ceramic back shell 2. Healthy GT4: Using the latest Huawei Truseen5.5+ algorithm, the results will be more accurate. GT3pro: Added ECG electrocardiogram and blood vessel and safety

Fix: Snipping tool not working in Windows 11 Fix: Snipping tool not working in Windows 11 Aug 24, 2023 am 09:48 AM

Why Snipping Tool Not Working on Windows 11 Understanding the root cause of the problem can help find the right solution. Here are the top reasons why the Snipping Tool might not be working properly: Focus Assistant is On: This prevents the Snipping Tool from opening. Corrupted application: If the snipping tool crashes on launch, it might be corrupted. Outdated graphics drivers: Incompatible drivers may interfere with the snipping tool. Interference from other applications: Other running applications may conflict with the Snipping Tool. Certificate has expired: An error during the upgrade process may cause this issu simple solution. These are suitable for most users and do not require any special technical knowledge. 1. Update Windows and Microsoft Store apps

How to encapsulate input components and unified form data in vue3 How to encapsulate input components and unified form data in vue3 May 12, 2023 pm 03:58 PM

Preparation Use vuecreateexample to create a project. The parameters are roughly as follows: use native input. Native input is mainly value and change. The data needs to be synchronized when changing. App.tsx is as follows: import{ref}from'vue';exportdefault{setup(){//username is the data constusername=ref('Zhang San');//When the input box changes, synchronize the data constonInput=;return( )=>({

How to implement laravel input hidden field How to implement laravel input hidden field Dec 12, 2022 am 10:07 AM

How to implement the laravel input hidden field: 1. Find and open the Blade template file; 2. Use the method_field method in the Blade template to create a hidden field. The creation syntax is "{{ method_field('DELETE') }}".

How to Fix Can't Connect to App Store Error on iPhone How to Fix Can't Connect to App Store Error on iPhone Jul 29, 2023 am 08:22 AM

Part 1: Initial Troubleshooting Steps Checking Apple’s System Status: Before delving into complex solutions, let’s start with the basics. The problem may not lie with your device; Apple's servers may be down. Visit Apple's System Status page to see if the AppStore is working properly. If there's a problem, all you can do is wait for Apple to fix it. Check your internet connection: Make sure you have a stable internet connection as the "Unable to connect to AppStore" issue can sometimes be attributed to a poor connection. Try switching between Wi-Fi and mobile data or resetting network settings (General > Reset > Reset Network Settings > Settings). Update your iOS version:

What to do if there is no cursor when clicking on the input box What to do if there is no cursor when clicking on the input box Nov 24, 2023 am 09:44 AM

Solutions for clicking the input box without a cursor: 1. Confirm the focus of the input box; 2. Clear the browser cache; 3. Update the browser; 4. Use JavaScript; 5. Check the hardware device; 6. Check the input box properties; 7. Debug JavaScript code; 8. Check other elements of the page; 9. Consider browser compatibility.

php提交表单通过后,弹出的对话框怎样在当前页弹出,该如何解决 php提交表单通过后,弹出的对话框怎样在当前页弹出,该如何解决 Jun 13, 2016 am 10:23 AM

php提交表单通过后,弹出的对话框怎样在当前页弹出php提交表单通过后,弹出的对话框怎样在当前页弹出而不是在空白页弹出?想实现这样的效果:而不是空白页弹出:------解决方案--------------------如果你的验证用PHP在后端,那么就用Ajax;仅供参考:HTML code

Detailed explanation of input box binding events in Vue documents Detailed explanation of input box binding events in Vue documents Jun 21, 2023 am 08:12 AM

Vue.js is a lightweight JavaScript framework that is easy to use, efficient and flexible. It is one of the most popular front-end frameworks currently. In Vue.js, input box binding events are a very common requirement. This article will introduce the input box binding events in the Vue document in detail. 1. Basic concepts In Vue.js, the input box binding event refers to binding the value of the input box to the data object of the Vue instance, thereby achieving two-way binding of input and response. In Vue.j

See all articles