我要更改所选月份的引导日期时间选择器输入值,并在更改时必须对其执行一些任务
我尝试了更改功能并将ID分配给输入,但无法正常工作
`$('#datetimepicker1').datetimepicker({
format: "MMM-YYYY",
viewMode: "months",
});`
`$('#datetimepicker1').on('change',function(){
var month=$(this).val();
alert(month);
$('#submit').show();
$.ajax({
url:'<?php echo site_url('payment/get_payroll_by_month');?>',
type:'POST',
dataType: 'json',
data:{month:month},
success: function(result) {
console.log(result);
$('td #employee').each(function(){
var emp=$(this).val();
var tr =$(this).closest('tr');
for (i = 0; i < result.length; i++) {
if(result[i].employee==emp)
{
tr.find('.status').text(result[i].status);
}
}
});
}
});
});`
`<div class="col-md-3">
<label for="status">Select Month:</label>
<div class='input-group date'>
<input type='text' class="form-control" id='datetimepicker1' name="from_date" />
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
`
答案 0 :(得分:0)
事件为dp.change
:
$('#datetimepicker1').on('dp.change',function(e){
var month= e.date;
alert(month);
$('#submit').show();
$.ajax({
url:'<?php echo site_url('payment/get_payroll_by_month');?>',
type:'POST',
dataType: 'json',
data:{month:month},
success: function(result) {
console.log(result);
$('td #employee').each(function(){
var emp=$(this).val();
var tr =$(this).closest('tr');
for (i = 0; i < result.length; i++) {
if(result[i].employee==emp)
{
tr.find('.status').text(result[i].status);
}
}
});
}
});
});
请参阅:https://eonasdan.github.io/bootstrap-datetimepicker/Events/