如何更改代码点火器中模式确认警报确定按钮的状态?



我已经设置了模式警报来更改状态,但仅在打开模式警报时状态会自动更改。如何仅在单击模态按钮时更改状态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);     
}

我的网页

<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">&times;</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");
}
});
}
}

=>你的HTML代码

$('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>');

在选择中,您必须以这种方式编写代码

'<a title="Change Status" class="btn btn-danger btn-xs" data-user="' + id + '" data-status="' + data + '" href="#UnbilledModal" data-toggle="modal" onclick="change_status(this)">Disable</a>'

<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">&times;</button>
<?php echo form_open('your url', array('class' => 'form-horizontal', 'name' => 'your form name')); ?>
<input type="hidden" name="id" /> //fetch id and status
<input type="hidden" name="status" />
<h4 class="modal-title">Do You Need update status into billed ?</h4></div>
<div class="pull-right">
<button type="button" class="btn btn-default" data-dismiss="modal">No</button>
<button type="submit" class="btn btn-success">Yes</button>
</div>
<?php echo form_close(); ?>
<div class="modal-footer">
<button type="submit"  class="btn btn-primary option">OK</button>
</div>
</div>
</div>
</div>

=>你的Javascript代码

function change_status(obj) {
var id = $(obj).data('id');         
var status = $(obj).data('status'); // here you can fetch data value 
$('input[name="id"]').val(id);
$('input[name="status"]').val(status);// use in modal right
}
function show_modal(obj) {
var modal_id = $(obj).attr('href');
var content = $(modal_id).children('div.modal-dialog').children('div.modal-content');
var data_url = $(obj).attr('data-url');
$.ajax({
url: data_url,
dataType: "html",
catch : false,
success: function (data) {
$(content).html(data);
}
});
}

相关内容

  • 没有找到相关文章

最新更新