将ID复选框传递到模式窗口

时间:2019-03-18 01:37:14

标签: checkbox modal-dialog

我想在按下“奖励”按钮后将ID从复选框传递到模式。我只想向在模态窗口内选择的那个插入奖励值。我只是不知道我的编码是否正确。

将Php插入数据库 `if(isset($ _ REQUEST ['bonus'])){

    //$ch = "check";
    $bonus = $_POST['bonus'];
    $chk= $_REQUEST['check_list'];
    $a=implode(",",$chk);

    echo $a;
    $query2 = "Update payroll set payroll_bonus = ('$bonus') where user_id in ($a) ";

    $result2 = mysqli_query($conn, $query2);

}`

用于奖励按钮

<!-- Button Bonus -->
        <div class="row mb-2">
        <div class="col-sm-12" align='right'>
                <a href="#ModalCenter" data-toggle="modal" data-id="<?php echo $row['user_id']?>">
                <button type="submit" name= "hantar" class="btn btn-sm btn-primary">Bonus</button>
                </a>
        </div>
        </div>
        <!-- /.Button Bonus -->

对于模式奖金

<!-- Modal Bonus -->

                                                                                    Bonker Pekerja                                  ×                                                   

            <div class="card-body">
            <div class="form-group">
                <label>Masukkan Bonus (%)</label>
                <input name="bonus" type="text" class="form-control" >
                <input type="hidden" name="bonus">
            </div>
            </div>

            <!-- /.card-body -->

        <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
        <button class="btn btn-primary" name="bonus">Save changes</button>
        </div>
        </div>
        </div>
        </div>
        </div>

  

用于奖励Javascript

<script>

$('#ModalCenter')。on('show.bs.modal',function(e){     var bonus = $(e.relatedTarget).data('bonus');

$(e.currentTarget).find('input[name="bonus"]').val(bonus);
  //$('#message').html(id);
});

Bonus Page Pic

0 个答案:

没有答案