Javascript Calendar deselecting date when date is

2019-08-30 09:39发布

问题:

I use a calendar from No Gray, found at http://www.nogray.com/calendar.php, and I have realised that the problems I have been having is due to when you click on the same date that has already been selected, it deselects the date instead of reselecting it again and if it is passed through in a form, the value for that field is empty.

I have read up on the use of the software and the options and the only option I can see that may help is the "ng.Calendar.is_selected" found at http://www.nogray.com/api/calendar/is_selected.php, and I am not sure if that is correct, but even on their demo on their own website, it works the same way and deselects the date instead of reselecting it.

I have tried everything but can't get it to perform where if you click the same date that is already selected, it does not deselect the date and just reselects it.

The example is here http://www.nogray.com/example.php?ID=260.

How can this been done please as I have tried now for a week with no joy.

Thank you in advance.

回答1:

This example might help, but the user won't be able to unselect a date unless they clear the input field.

<input id="forced_click_select" type="text">
<script src="PATH/TO/ng_all.js" type="text/javascript"></script>
<script src="PATH/TO/components/calendar.js" type="text/javascript"></script>
<script type="text/javascript">
ng.ready( function() {
    var fcs_cal = new ng.Calendar({
        input: 'forced_click_select',
        events: {
            onDateClick: function(dt){
                this.select_date(dt);
            }
        }
    })
});
</script>

http://www.nogray.com/example.php?ID=307