1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Datepicker disabled dates from text file

Discussion in 'JavaScript' started by Ron4242, Nov 10, 2017.

  1. #1
    I have 14 datepickers on my site. It is a hassle when a date gets disabled. I've looked for an easier way to disable dates on all calendars. I heard there is a way to have the datepickers read the disabled dates from a separate text file, that could be updated easily. I've looked for this solution on the Internet but have found nothing. Can someone tell me how to make the datepicker code below read the disable date variables from a separate text file?

    
    <!--start datepicker -->
    <script type="text/javascript">
    var unavailableDates = ["12-12-2017","9-12-2017"];
    function unavailable(date) {
    dmy = date.getDate() + "-" + (date.getMonth() + 1) + "-" + date.getFullYear();
    if ($.inArray(dmy, unavailableDates) == -1) {
    return [true, ""];
    } else {
    return [false, "", "Unavailable"];
    }
    }
    $(function() {
    $( "#datepicker1, #datepicker2" ).datepicker({
    dateFormat: 'mm/dd/yy',
    beforeShowDay: unavailable,
    minDate: 2,
    });
    });
    </script>
    <!--end datepicker -->
    
    Code (markup):
     
    Ron4242, Nov 10, 2017 IP