我的问题是: 我有两种不同的日期选择器,一种用于日期,一种用于时间。 我尝试使用php $ _GET [];获取选定的日期和时间值。 当我选择日期时,我会得到日期值,但是当我选择时间时,我会失去日期,但我会得到时间或反之。所以我的问题是我该如何附加这两个值?
谢谢(对不起我的英语不好)
以下是代码:
jQuery('#datetimepicker2').datetimepicker({
datepicker:false,
format:'H:i',
onChangeDateTime:function(dp,$input){
var selected_time = $input.val()
window.location.search ="time="+ selected_time;
}
});
jQuery('#datetimepicker3').datetimepicker({
format:'Y-m-d',
inline:true,
timepicker:false,
onChangeDateTime:function(dp,$input){
var selected_date_time2 = document.getElementById("datetimepicker2").value;
var selected_date_time = $input.val()
window.location.search ="date=" + selected_date_time+"&";
}
});
答案 0 :(得分:0)
已修复localStorage
jQuery('#datetimepicker2').datetimepicker({
datepicker:false,
format:'H:i',
stepping: 15,
onChangeDateTime:function(dp,$input){
var selected_time = $input.val()
localStorage.setItem("time", selected_time);
var date = localStorage.getItem("date");
window.location.search ="date="+date+"&time="+selected_time;
}
});
jQuery('#datetimepicker3').datetimepicker({
format:'Y-m-d',
inline:true,
timepicker:false,
dayOfWeekStart: 1,
onChangeDateTime:function(dp,$input){
var selected_date_time2 = document.getElementById("datetimepicker2").value;
var selected_date = $input.val()
localStorage.setItem("date", selected_date);
var time = localStorage.getItem("time");
window.location.search ="date="+selected_date+"&time="+time;
}
});