简体   繁体   English

具有可点击事件的jQuery日历

[英]jQuery Calender With Clickable Events

I have created a jQuery calender with highlighting selected date. 我创建了一个jQuery日历,突出显示了选定的日期。 I want to display the events on the selected date from database. 我想显示数据库中所选日期的事件。 I stored the selected date in variable "x" but how do I link the javascript variable with "x" so that I can compare the date with events on that date in database and display those events in the corresponding div? 我将所选日期存储在变量“ x”中,但是如何将javascript变量与“ x”链接,以便可以将日期与该日期在数据库中的事件进行比较,并在相应的div中显示这些事件?

<div id="calendar"></div>
Date:<input type="text" id="datepicker_send" name="datepicker_send" readonly="readonly">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> 
<script src="/jquery-ui-datepicker.min.js"></script>
<script>

var x='';

    $('#calendar').datepicker({
        altField: '#datepicker_send',
        inline: true,
        firstDay: 1,
        showOtherMonths: true,
        altFormat: "dd/mm/yy",
        dateFormat: "dd/mm/yy",
        dayNamesMin: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
        onSelect: function(dateText){
            $('#event-date').text(dateText)
            x=dateText;
            //alert(x);
            }  
        });
</script>

You can call an ajax function which will check the events for that particular date in database.You will get the response and can show the events in alert, tooltip or in any div as you wish. 您可以调用ajax函数,该函数将检查数据库中该特定日期的事件。您将获得响应,并可以根据需要在警报,工具提示或任何div中显示事件。

onSelect: function(dateText){
 $('#event-date').text(dateText)      
 // call ajax function here and send dateText
}  

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM