Cara pemberian id pada tiap foreach untuk modal

saya kurang paham untuk memunculkan modal untuk tiap foreach..

<div class="content-wrapper" lang="id">
    <section class="content-header">
        <h1>Surveilans</h1>
    </section>

    <section class="content">
        <form action="" method="get" id="">
            <div class="box box-solid">
                <div class="box-body">
                    <div class="row">
                        <div class="col-md-12">
                            <fieldset style="font-family:tahoma; font-size:12px">
                                <div class="col-md-6">
                                    <div class="form-group">
                                        <label class="control-label">Periode</label>
                                        <input type="date" class="form-control" name="date">
                                        <br>
                                        <input type="submit" value="Tampil">
                                    </div>
                                </div>
                            </fieldset>
                            <center>
                                <h2>HASIL SURVEILANS HAIS - <?= get_detail_tgl(date('Y-m'))?></h2>
                            </center>
                            <table class="">
                                <tbody>
                                    <tr>
                                        <th scope="col">No</th>
                                        <th scope="col">Indikator</th>
                                        <th align="center" colspan="2">1</th>
                                        <th align="center" colspan="2">2</th>
                                        <th align="center" colspan="2">3</th>
                                        <th align="center" colspan="2">4</th>
                                        <th align="center" colspan="2">5</th>
                                        <th align="center" colspan="2">6</th>
                                        <th align="center" colspan="2">7</th>
                                        <th align="center" colspan="2">8</th>
                                        <th align="center" colspan="2">9</th>
                                        <th align="center" colspan="2">10</th>
                                        <th align="center" colspan="2">11</th>
                                        <th align="center" colspan="2">12</th>
                                        <th align="center" colspan="2">13</th>
                                        <th align="center" colspan="2">14</th>
                                        <th align="center" colspan="2">15</th>
                                        <th align="center" colspan="2">16</th>
                                        <th align="center" colspan="2">17</th>
                                        <th align="center" colspan="2">18</th>
                                        <th align="center" colspan="2">19</th>
                                        <th align="center" colspan="2">20</th>
                                        <th align="center" colspan="2">21</th>
                                        <th align="center" colspan="2">22</th>
                                        <th align="center" colspan="2">23</th>
                                        <th align="center" colspan="2">24</th>
                                        <th align="center" colspan="2">25</th>
                                        <th align="center" colspan="2">26</th>
                                        <th align="center" colspan="2">27</th>
                                        <th align="center" colspan="2">28</th>
                                        <th align="center" colspan="2">29</th>
                                        <th align="center" colspan="2">30</th>
                                        <th align="center" colspan="2">31</th>
                                    </tr>
                                    <?php foreach($indikator->result_array() as $row){ ?>
                                    <tr>
                                        <td><?= $row['id'] ?></td>
                                        <td><?= $row['nama_indikator']?></td>
                                        <td>
                                            <a href="" type="button" class="input-indikator" data-toggle="modal" style="text-decoration:underline; position:relative; width:25px; color:blue" colspan="2">0</a>
                                        </td>
                                    </tr>
                                    <?php }?>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </section>
</div>

<!-- Modal -->
<div class="modal fade" id="mutu-modal" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">×</span>
                </button>
                <h5 class="modal-title">Input </h5>
            </div>
                <div class="modal-body">
                    <text></text>
                </div>
                <div class="modal-footer">
                    <button type="submit" class="btn btn-primary">Simpan</button>
                    <button type="button" class="btn btn-success" data-dismiss="modal" >Edit</button>
                </div>
            </div>
        </div>
    </div>
</div>

untuk jquerynya

<script>
$('.input-indikator').on('click', function (event) {
    event.preventDefault();
    var postBody = $(this).parents('.post').find('.').text();
    $('#mutu-modal .modal-body').text(postBody);
    $('#mutu-modal').modal();
});
</script>

Terima Kasih

avatar dvnwrkrsn
@dvnwrkrsn

3 Kontribusi 0 Poin

Dipost 3 tahun yang lalu

Belum ada Jawaban. Jadi yang pertama Jawaban

Login untuk ikut Jawaban