Javascript 使用Jquery完整日历获取今日日期
我使用的是Jquery FullCalendar.js文件版本FullCalendar v2.2.5 我五月份有一次潜水 这是我的jquery代码Javascript 使用Jquery完整日历获取今日日期,javascript,jquery,Javascript,Jquery,我使用的是Jquery FullCalendar.js文件版本FullCalendar v2.2.5 我五月份有一次潜水 这是我的jquery代码 <script type="text/javascript"> $(document).ready(function () { $('#jweek').fullCalendar('today'); }); </script> 动态复选框列表的代码 <
<script type="text/javascript">
$(document).ready(function () {
$('#jweek').fullCalendar('today');
});
</script>
动态复选框列表的代码
<script>
$(document).ready(function () {
var checkedvalue = [];
$.ajax({
type: "POST",
url: "WebForm1.aspx/GetRole",
data: '',
//data: JSON.stringify(obj),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (data) {
var json = JSON.parse(data.d);
var val = 0;
var table = $('<table></table>');
var option = json.map(x =>
table.append($('<tr></tr>').append($('<td></td>').append($('<input>').attr({
type: 'checkbox', name: 'chkRoles', value: x.chkName, id: 'chkrole' + val
}))).append(
$('<label>').attr({
for: 'chkRoles' + val++
}).text(x.chkName))));
$('#chkrole').append(table);
}
});
$("#btnget").click(function () {
checkedvalue = [];
$("input[name=chkRoles]").each(function () {
if ($(this).is(":checked")) {
checkedvalue.push($(this).val());
}
});
$("#lblSelected").text(checkedvalue);
});
});
</script>
正如你们在上面的动态复选框列表中所看到的,我想传递日历的当前日期,并基于此,我想生成未来7天的复选框列表。我希望我的问题是清楚的,对不起我的英语
这是我的web方法,我想传递当前日历日期,这样就可以通过循环
[WebMethod()]
// Get current select date from calender and generate next 7 days inside the //checkbox
public static string GetRole()
{
//Use the date which is passed
DateTime today = '';
DataTable dt = new DataTable();
dt.Columns.Add("Id", typeof(int));
dt.Columns.Add("chkName", typeof(string));
for (int i = 1; i <= 7; i++)
{
}
return JsonConvert.SerializeObject(dt);
}
您可以使用下面的简单javascript代码获得今天的日期:-
var d = new Date();
var month = d.getMonth()+1;
var day = d.getDate();
var output = d.getFullYear() + '/' + ((''+month).length<2 ? '0' : '') + month + '/' + ((''+day).length<2 ? '0' : '') + day;
alert(output);
目前,我将当前日期值存储在输出变量中。您可以根据需要输入值。是否要设置日期格式,但无法设置?@hasan05 sir当我运行页面时,日期不显示,我希望以上述格式显示日期,以及任何控制台错误?@hasan05 no sir控制台中也不显示任何内容。您能告诉我以何种方式显示当前日期吗divVarma Lanke不是sir它显示消息[对象对象]你是对的,但我的整个项目取决于FullCalendar,当我在Calendar中单击下一个或上一个按钮时,我想更新我的动态复选框列表,我需要将日历的当前日期传递到某个地方我正在更新代码,请检查它
var custom_format= $('#YourCalendar').fullCalendar('getDate');
var calDate = custom_format.format('DD.MM.YYYY HH:mm'); //Here you can format your Date
var d = new Date();
var month = d.getMonth()+1;
var day = d.getDate();
var output = d.getFullYear() + '/' + ((''+month).length<2 ? '0' : '') + month + '/' + ((''+day).length<2 ? '0' : '') + day;
alert(output);
var custom_format= $('#YourCalendar').fullCalendar('getDate');
var calDate = custom_format.format('DD.MM.YYYY HH:mm'); //Here you can format your Date