我正在为我的项目使用jquery datetimepicker插件。我已经创建了用于daynamically创建datepicker的JavaScript函数。它适用于所有输入文本框。但我想在show函数上动态设置startdate。我已经在setfromDate_limit函数中为它编写代码。在这个函数中,我已经通过了日期控制对象。它的设置最小和最大日期完美,但不是开始日期。所以,请帮助我如何设置STARTDATE动态jquery datetimepicker startDate无法正常工作
dateTimePicker的网址:http://xdsoft.net/jqplugins/datetimepicker/
function create_datepicker(controlId,idx,flg_day,startday)
{
var control="#"+controlId;
var startdayflag=0;
var cnt=jQuery(control).datetimepicker({
format:'Y-m-d',
scrollMonth:false,
scrollInput:false,
defineCustomWeekend:true,
defaultSelect:defaultselect.replace(/\-/g, '/'),
startDate:"<?php echo date('Y-m-d'); ?>",
onClose:function(){
if(flg_day)
{
calulate_days(idx);
}
},
onChangeDateTime:function(){
if(flg_day)
{
for (i = idx+1; i < $("input[name ^=end_dt]").length; i++) {
$("#start_dt_"+i).val("");
$("#end_dt_"+i).val("");
$("#no_of_days_"+i).val("");
}
}
},
onShow:function(){
if(flg_day)
{
setDate_limit(this,idx) // to date
}
else{
setfromDate_limit(this,idx) // from date
}
},
timepicker:false
});
}
function setfromDate_limit(obj,idx)
{
if(idx == 0)
return;
else if(idx == 0 && obj=='')
return;
else
var full_date=get_prev_date(idx);
if(full_date != '')
{
var actualDate = new Date(full_date);
//alert(actualDate);
actualDate.setDate(actualDate.getDate()+1);
full_date=actualDate.getFullYear()+"/"+(actualDate.getMonth()+1)+"/"+actualDate.getDate();
var startday=actualDate.getFullYear()+"-"+(actualDate.getMonth()+1)+"-"+actualDate.getDate();
var mindt=full_date;
//obj.startDate="2015-09-19";
obj.setOptions({
startDate:startday,
minDate:mindt,
maxDate:mindt
})
return;
}
return;
}
你为什么把''在双引号 –
@ AmitSoni我已经在我的PHP脚本中写这段代码,我想设置服务器日期而不是客户端PC日期,所以我写这个 – Hkachhia