php - 用数据表中的数据填充引导-4 模态(服务器端)

我有一个带有数据表的PHP程序(服务器端!!

http://img2.mukewang.com/6330453c0001e84204710450.jpg

每行都有一个按钮(“管理”),单击该按钮时,将打开引导 4 模式:

http://img1.mukewang.com/633045460001230304810294.jpg

我需要用包含单击的按钮的行中的数据填充模式的2元素。


任何提示将不胜感激。


断续器 :


<body>

<div id="manageModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="manageAccountModal" aria-hidden="true">

    <div class="modal-dialog" role="document">

        <div class="modal-content border border-dark">

            <form id="manageModalForm" name="manageModalForm" action="" method="POST" role="form" class="p-2 needs-validation" novalidate>

                <div class="modal-body">

                    <div>

                        Id<a id="accUserId" name="accUserId" class="form-control"></a>

                        <br>

                    </div>

                    <div class="form-group">

                        User Name<input id="accUserName" name="accUserName" type="text" class="form-control">

                    </div>

                </div>

                <div id="manageModalActions" class="modal-footer myLightPurpleBgColor rounded">

                    <div class="col-8">

                        <div class="row">

                            <div class="col-4">

                                <button type="button" class="btn btn-secondary text-light border border-dark myBigBtn font-weight-bold" data-dismiss="modal"><h7>Cancel</h7></button>

                            </div>

                        </div>

                    </div>

                </div>

            </form>

        </div>

    </div>

</div>

<div class="container-fluid">

    <div class="jumbotron jumbotron-fluid mr-n2 ml-n2 mb-n2 rounded bg-secondary">

        <div class="container">

            <div class="row">

                <div class="col-lg-12 col-lg-offset-2 myMargTop20 bg-white rounded">

                    <table id="example" class="display table table-bordered table-hover dt-responsive nowrap rounded" cellspacing="0" width="100%">

                        <br>

                        <thead>

                            <tr>



炎炎设计
浏览 54回答 1
1回答

冉冉说

解决!将我的Java脚本更改为以下内容,它的工作原理是:&nbsp; &nbsp; <script>&nbsp; &nbsp; $(document).ready(function() {&nbsp; &nbsp; &nbsp; &nbsp; // ==============&nbsp; ==============&nbsp; &nbsp; &nbsp; &nbsp; var jsTable = $('#example').DataTable({ // added:&nbsp; &nbsp;var jsTable =&nbsp; &nbsp; &nbsp; &nbsp; // $('#example').dataTable({&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'scrollX': true,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'pagingType': 'numbers',&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'processing': true,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'serverSide': true,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'ajax': 'datatablesServerSide.php',&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "columnDefs": [{"render": createManageButtonFunc, "data": null, "targets": [0]}],&nbsp; &nbsp; &nbsp; &nbsp; });&nbsp; &nbsp; &nbsp; &nbsp; // ============== Next 7 lines were added ==============&nbsp; &nbsp; &nbsp; &nbsp; $('#example').on('click', 'tr', function(){&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // var jsData = jsTable.fnGetData(this);&nbsp; <== fnGetData deprecated!!!&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jsTable = $('#example').DataTable();&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var jsData = jsTable.row(this).data();&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $('#accUserId').text(jsData[1]);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $('#accUserName').val(jsData[2]);&nbsp; &nbsp; &nbsp; &nbsp; })&nbsp; &nbsp; &nbsp; &nbsp; // =====================================================&nbsp; &nbsp; });&nbsp; &nbsp; function createManageButtonFunc() {&nbsp; &nbsp; &nbsp; &nbsp; return '<button id="manageBtn" type="button" class="btn btn-success btn-xs" data-toggle="modal" data-target="#manageModal">Manage</button>';&nbsp; &nbsp; }</script>
打开App,查看更多内容
随时随地看视频慕课网APP