Newbie here, My target is, how can I pass the value of my amount column to my textbox? I did the same logic as i pass the ID using script (below), but it's not working. I'm trying different approach but none of them is working. Hoping someone can help. Thank you in advance.
Views:
<?php
foreach($result as $rows) { ?>
<?php if($rows->status==='pending'){ ?>
<tr>
<td><?php echo $rows->userID; ?></td>
<td><?php echo $rows->transID; ?></td>
<td><?php echo $rows->amount; ?></td>
<td><?php echo $rows->currentBalance; ?></td>
<td><?php echo $rows->status; ?></td>
<td>
<button data-id="<?php echo $rows->transID?>" ustatus="approved" class="showmodal fundTable btn btn-success btn-sm text-bold user_status">
<?php echo $rows->transID?> accept
</button>
<div id="fundModal" class="modal" tabindex="-1" role="dialog">
<form method="post" action="<?php echo site_url('ewallet/statuschanged')?>">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Modal title</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div class="form-group">
<label for="">transID</label>
<input type="text" id="transID" name="transID" value="">
</div>
<div class="form-group">
<label for="">Amount</label>
<input type="text" id="amount" name="amount" value="<?php echo $rows->amount; ?>">
</div>
<div class="form-group">
<label for="">Status</label>
<input type="text" name="status" id="user_status" value="">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-primary">Save changes</button>
</form>
</div>
</div>
</div>
</div>
Controllers:
public function statuschanged($transID = 0)
{
$this->ewallets->statuss($transID);
}
Model:
function statuss($transID) {
$transID = $this->input->post('transID');
$status = $this->input->post('status');
$data = array('status' => $status );
$this->db->where('transID',$transID);
$this->db->update('cash_out', $data); //Update status here
return redirect('ewallet/cashout');
}
Script:
<script>
$('.showmodal').on('click', function(e){
e.preventDefault();
$('#transID').val(this.dataset.id); // passing of ID to my textbox
$('#fundModal').modal('show')
})
$('#fundModal').on('hidden.bs.modal', function () {
$('#transID').val('')
$('#ustatus').val('')
})
</script>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…