程序问答   发布时间:2022-06-01  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了填充表格时向json添加按钮大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

如何解决填充表格时向json添加按钮?

开发过程中遇到填充表格时向json添加按钮的问题如何解决?下面主要结合日常开发的经验,给出你关于填充表格时向json添加按钮的解决方法建议,希望对你解决填充表格时向json添加按钮有所启发或帮助;

我试图在动态填充表格时插入一个按钮。我有正确加载表格的数据,我可以插入按钮。当我单击按钮时,它会显示警报框以检查它是否正常工作。但是,当我尝试获取该行第一个单元格的数据时,会出现 $ 未定义的错误。

这是我的代码:

<?php
            $file = 'data.Json';
            $data = file_get_contents($filE);
            $Json = Json_decode($data);
            echo"<pre>";
            print_r($Json);
            echo"</pre>";
        ?>
        <form method="POST" action="">
            <center><button class="btn btn-priMary" name="display">Populate</button></center>
        </form>
    </div>
    <table class="table table-b@R_262_5316@ table-example">
<thead class="alert-info">
    <tr>
        <th>Firstname</th>
        <th>Lastname</th>
        <th>Age</th>
    </tr>
</thead>
<tbody>
    <?php
        $url = 'data.Json';
        $data = file_get_contents($url);
        $Json = Json_decode($data);
        
        foreach($Json as $member){
    ?>
    <tr>
        <td><?php echo $member->firstname?></td>
        <td><?php echo $member->lastname?></td>
        <td><?php echo $member->gender?></td>
        <td><button class="btn btn-info button-details" onclick="MyFunction()">>detalhes</button> 
 </td>
    </tr>
    <?php
        }
    ?>
</tbody>
</table>
    <div class="col-md-6">
        <?php include 'populate_Json.php';?>
    </div>
</div>

<script type="text/JavaScript">

    
    function MyFunction() {
alert("botao funciona");
        
        $(".table-example").find("tr td:first"); *this is not working
        
}

解决方法

将其包含在您的 html 头中:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

大佬总结

以上是大佬教程为你收集整理的填充表格时向json添加按钮全部内容,希望文章能够帮你解决填充表格时向json添加按钮所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: