【发布时间】:2018-09-15 02:48:44
【问题描述】:
我已设置模态警报以更改状态,但仅在打开模态警报时状态会自动更改。如何仅在单击模态的ok按钮时更改状态?
我的控制器
public function Changetobilledstatus()
{
$id=$this->input->post('value');
$data=array('Rental_status'=>3);
$this->General_model->update($this->table,$data,'RA_id',$id);
echo json_encode($data);
}
我的 html
<div id="UnbilledModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Do You Need update status into billed ?</h4></div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary option">OK</button>
</div>
</div>
</div>
</div>
我的脚本
$('td', row).eq(10).html('<center><select id="Rental_status" onchange="changeStatus('+data['RA_id']+')"><option value="1">Select</option><option value="2">Billed</option></select></center>');
function changeStatus(RA_id){
var val=$("#Rental_status").val();
var id= RA_id;
if(RA_id){
$.ajax({
url:"<?php echo base_url()?>index.php/Rental_agreement/Changetobilledstatus",
type: 'POST',
data: {value:RA_id},
dataType: 'json',
success:
function(data)//quotation_status
{
//location.reload();
//alert(data['quantity']);
$('#UnbilledModal').modal();
},
error:function(e){
console.log("error");
}
});
}
}
【问题讨论】:
-
什么状态?什么是自动更改的?
-
我需要在点击模式确定按钮时将租赁状态字段更新为 3
-
好的,但是为什么要使用选择框呢?如果您将有 1 个“计费”选项,为什么要让用户从下拉列表中选择?只需单击即可打开模式。如果用户点击确定,则它会更改状态。更简单、更好的用户体验。
标签: jquery codeigniter codeigniter-3 codeigniter-2