繁体   English   中英

为什么表数据的模态引导程序在弹出时不显示/获取匹配数据?

[英]Why modal bootstrap on table data doesn't showing / fetching match data when popup?

请检查这张图片

我尝试使用模式引导程序获取每个表数据的数据,但是当我单击每个模式按钮时,它只是以我的弹出模式的形式显示最后一个表数据。 我希望数据以模态引导程序的形式存在。 我正在使用 CodeIgniter。请帮助我,谢谢。 GBU

这是我的代码:

<table class="table table-bordered table-striped nowrap text-gray-900" id="dataTable" width="100%" style="font-size: 13px;" cellspacing="0">
                    <thead>
                        <tr class="table-success">
                            <th>ID</th>
                            <th>NOMOR</th>
                            <th>KODE</th>
                            <th>TINDAKAN</th>
                            <th>AKSI</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php
                        foreach ($prosedur_rehab as $rehab) {
                        ?>
                            <tr>
                                <td><?= $rehab->ID; ?></td>
                                <td><?= $rehab->NOMOR; ?></td>
                                <td><?= $rehab->KODE; ?></td>
                                <td><?= $rehab->TINDAKAN; ?></td>
                                <td>
                                    <button type="button" class="btn btn-sm btn-info" data-toggle="modal" data-target="#perawat<?php echo $rehab->ID;?> ">
                                            <i class="fas fa-user-nurse"></i>
                                    </button>
                                    <div class="modal fade" id="perawat<?php echo $rehab->ID;?>" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true" >
                                            <div class="modal-dialog modal-lg" >
                                                <div class="modal-content">
                                                    <div class="modal-header" style="background-color:#5bc0de">
                                                        <h5 class="modal-title" id="exampleModalLabel">Kelola Rawat Jalan (Diisi Oleh Perawat)</h5>
                                                        <button type="button" class="btn-danger" data-dismiss="modal" aria-label="Close">
                                                        <span aria-hidden="true">&times;</span>
                                                        </button>
                                                    </div>
                                                    <div class="modal-body">
                                                        <form method="post" action="<?php echo base_url().'dokter/kunjungan/kirimlaprajal'?>">
                                                            <div class="form-group">
                                                                    <!-- <label for="exampleInputEmail1">ID</label> -->
                                                                    <select name="" class="form-control">
                                                                        <option>-- CARI --</option>
                                                                        <?php foreach ($prosedur_rehab as $rehab):?>
                                                                            <option value="<?php echo $rehab->ID?>"><?php echo $rehab->ID?> || <?php echo $rehab->NORM?></option>
                                                                        <?php endforeach ?>
                                                                    </select>
                                                            </div>
                                                            
                                                            <div class="form-group">
                                                                <label for="exampleInputEmail1">ID Prosedur</label>
                                                                <input type="text" name="ID" class="form-control" id="exampleInputEmail1" required readonly autocomplete="off" value="<?php echo $rehab->ID; ?>">
                                                            </div>
                                                            
                                                            <div class="row">
                                                                <div class="col-6">
                                                                    <div class="form-group">
                                                                        <label for="exampleInputEmail1">No. Pendaftaran</label>
                                                                        <input type="text" name="NOMOR" class="form-control" id="exampleInputEmail1" required readonly autocomplete="off" value="<?php echo $rehab->NOMOR; ?>">
                                                                    </div>
                                                                    <div class="form-group">
                                                                        <label for="exampleInputEmail1">Kode</label>
                                                                        <input type="text" name="KODE" class="form-control" id="exampleInputEmail1" required readonly autocomplete="off" value="<?php echo $rehab->KODE; ?>">
                                                                    </div>
                                                                    <div class="form-group">
                                                                        <label for="exampleInputEmail1">Tindakan</label>
                                                                        <input type="text" name="TINDAKAN" class="form-control" id="exampleInputEmail1" autocomplete="off" value="<?php echo $rehab->TINDAKAN; ?>">
                                                                    </div>
                                                                    <div class="form-group">
                                                                        <label for="exampleInputEmail1">Tanggal</label>
                                                                        <input type="datetime-local" name="TANGGAL" class="form-control" id="exampleInputEmail1" required autocomplete="off" placeholder="" value="">
                                                                    </div>
                                                                    <div class="form-group">
                                                                        <label for="exampleInputEmail1">Instrumen Uji Fungsi</label>
                                                                        <input type="text" name="PROGRAM" class="form-control" id="exampleInputEmail1" required autocomplete="off" value="">
                                                                    </div>
                                                                    <div class="form-group">
                                                                        <label for="exampleInputEmail1">Hasil</label>
                                                                        <input type="text" name="HASIL" class="form-control" id="exampleInputEmail1" required autocomplete="off" placeholder="" value="">
                                                                    </div>
                                                                </div>
                                                                <div class="col-6">
                                                                    <div class="form-group">
                                                                        <label for="exampleInputEmail1">Kesimpulan</label>
                                                                        <input type="text" name="KESIMPULAN" class="form-control" id="exampleInputEmail1" required autocomplete="off" value="">
                                                                    </div>
                                                                    <div class="form-group">
                                                                        <label for="exampleInputEmail1">Rekomendasi</label>
                                                                        <input type="text" name="REKOMENDASI" class="form-control" id="exampleInputEmail1" required autocomplete="off" value="">
                                                                    </div>
                                                                    
                                                                    <div class="form-group">
                                                                        <label for="exampleInputEmail1">Oleh</label>
                                                                        <input type="text" name="OLEH" class="form-control" id="exampleInputEmail1" required autocomplete="off" value="<?php echo $session_user->nip ;?>" readonly>
                                                                    </div>
                                                                    <div class="form-group">
                                                                        <label for="exampleInputEmail1">Status</label>
                                                                        <input type="text" name="STATUS" class="form-control" id="exampleInputEmail1" required autocomplete="off" value="">
                                                                    </div>
                                                                    
                                                                </div>
                                                                  
                                                            </div>
                                                            
                                                            <button type="submit" name="simpen" class="btn btn-info float-right"><i class="fas fa-save"> </i> Simpan</button>
                                                        </form>    
                                                    </div>
                                                </div>
                                            </div> 
                                        </div>
                                </td>
                            </tr>
                        <?php } ?>
                    </tbody>
                    <tfoot>
                        <tr>
                            <th>ID</th>
                            <th>NOMOR</th>
                            <th>KODE</th>
                            <th>TINDAKAN</th>
                        </tr>
                    </tfoot>
                </table>

我试过你的代码,它工作得很好,检查你的 $rehave->ID 值,也许它没有值或值无效,或者检查你的模态插件在此处输入图像描述

问题是我在 select 选项中使用了相同的 foreach。 我忘记了我是否一直在使用第一个 foreach 来显示表数据,然后我在表单中再次使用它。

不要在表单中使用相同的 foreach,删除或更改它:

<select name="" class="form-control">
   <option>-- CARI --</option>
     <?php foreach ($prosedur_rehab as $rehab):?>
      <option value="<?php echo $rehab->ID?>"><?php echo $rehab->ID?> || <?php echo $rehab->NORM?></option>
     <?php endforeach ?>
</select>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM