社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  Jquery

使用jquery从动态按钮获取ID

froz • 6 年前 • 992 次点击  

我有从数据库获取值的PHP文件。 我很难从结果中得到一个动态的ID按钮。 我做错了吗?

这是我的密码

<!DOCTYPE HTML>
<html>
<head>
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <script>src="jquery-3.3.1.js"</script>
</head>
<body>
    <div class="container">
        <?php
        include("koneksi.php");
        $sql = "SELECT * FROM data_cv";
        $result = $conn->query($sql);
        ?>
        <div class="table-responsive">
        <table class="table table-bordered">
            <thead>
                <tr>
                    <th>Nama</th>
                    <th>Nomor Identitas</th>
                    <th>Tempat Lahir</th>
                    <th>Tanggal Lahir</th>
                    <th>Jenis SIM</th>
                    <th>Masa SIM</th>
                    <th>Nomor SKCK</th>
                    <th>Pendidikan</th>
                    <th>Nomor Telepon (Handphone)</th>
                    <th>Keterangan</th>
                    <th>Terima Berkas</th>
                    <th>Tindakan</th>
                </tr>
            </thead>
            <?php
            while ($row = mysqli_fetch_array($result)) {
                echo '
                <tr>
                <td>'.$row["nama"].'</td>
                <td>'.$row["id_ktp"].'</td>
                <td>'.$row["tempat_lahir"].'</td>
                <td>'.$row["tanggal_lahir"].'</td>
                <td>'.$row["jenis_sim"].'</td>
                <td>'.$row["masa_sim"].'</td>
                <td>'.$row["no_skck"].'</td>
                <td>'.$row["pendidikan"].'</td>
                <td>'.$row["no_telp"].'</td>
                <td>'.$row["keterangan"].'</td>
                <td>'.$row["terima_berkas"].'</td>
                <td><button id= "'.$row['id_ktp'].'" value="Accept"">Panggil</button></td>
                </tr>
                ';
            }
            $conn->close();
            ?>
            <script>
            $("button").click(function() {
            alert(this.id);
            });
        </table>
        </div>
    </div>
</body>
</html>

我的php文件结果是

php file result

我想当我点击这个按钮时,我会从他们基于PHP值的ID中得到警报。 请给我建议。

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/30862
 
992 次点击  
文章 [ 1 ]  |  最新文章 6 年前