i wanted to pass the id from the checkbox to modal once i pressed "bonus" button. I wanted to insert bonus value to only the one who were picked inside the modal window. I just don't know if my coding is correct.
For Php Insert to DB `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);
}`
For Bonus Button
<!-- 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 -->
For Modal Bonus
<!-- Modal Bonus -->
Bonus 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>
For Bonus 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);
});
Aucun commentaire:
Enregistrer un commentaire