Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8667899
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:04:50+00:00 2026-06-12T18:04:50+00:00

I have an array of unavailable dates set at unavailableDates and weekends. Array: <script

  • 0

I have an array of unavailable dates set at unavailableDates and weekends.

Array:

<script type="text/javascript">//<![CDATA[
var unavailableDates = [];
{foreach $fixed.rows as $row}
    var row = {};
    row['date_from'] = "{$row.fixed_date_from.value}";
    row['date_until'] = "{$row.fixed_date_until.value}";
    row['name'] = "{$row.fixed_name.value} ({$row.fixed_type.value})";
    unavailableDates.push(row);
{/foreach}
//]]></script>

Q1) How can I add an extra check for the until date. I have got it working as shown below for the from date?

Q2) Can I improve the code to use in_array instead of loop through each of the dates for each calendar day?

var days = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"];
var unavailableDays = ["Saturday","Sunday"];

$("#.datePicker").datepicker($.extend(true, {}, $.initDatePickers.defaults, {
    beforeShowDay: function(date) {
        ymd = date.getFullYear() + "-" + ("0"+(date.getMonth()+1)).slice(-2) + "-" + ("0"+date.getDate()).slice(-2);
        day = new Date(ymd).getDay();
        result = null;

        // Check if date in unavailable array or weekend
        for(var i = 0; i < unavailableDates.length; i++){
            if ((ymd == unavailableDates[i].date_from) && $.inArray(days[day], unavailableDays) < 0) {
                return [false,"unavailable",unavailableDates[i].name];
            }
        }

        if(result){
            return result;
        } else {
            return [true, "available", ""];
        }
    } 
}));
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T18:04:51+00:00Added an answer on June 12, 2026 at 6:04 pm

    Use the befreShowDay option to parse your data array to determine if day is selectable or not

    beforeShowDayType: Function( Date date )

    A function takes a date as a parameter and must return an array with [0] equal to true/false indicating whether or not this date is selectable, 1 equal to a CSS class name or “” for the default presentation, and [2] an optional popup tooltip for this date. It is called for each day in the datepicker before it is displayed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I have array of objects, when I type the name of variable in
I have array of objects: var aoo = [{},{},{},....{},{},{}]; I need a optimized function
I have a straight forward string array, why would IndexOf be unavailable? I'm targeting
I have array of two textboxes in a table, on blur of one text
I have array INPUTFILES with n files INPUTFILES=( file_0 ... files_n-1 ) And i
I have array of hashes: @array = [{:id => 1, :status=>R}, {:id => 1,
I have array of select tag. <select id='uniqueID' name=status> <option value=1>Present</option> <option value=2>Absent</option> </select>
I have array like this: $path = array ( [0] => site\projects\terrace_and_balcony\mexico.jpg [1] =>
I have array result like this: Array ( [0] => stdClass Object ( [id_global_info]
I have array of strings, String[] data and it's 10 elements has value P

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.