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 7811347
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T04:07:47+00:00 2026-06-02T04:07:47+00:00

I have 2 functions I wrote (mostly modified) that I need to combine into

  • 0

I have 2 functions I wrote (mostly modified) that I need to combine into one function. The first function is called when a user chooses a department, it does a callback to find days and adds them to an array. The second function blocks off days in a jQuery datepicker. I’ve gotten the blocked off days to work properly, I just can’t figure out how to combine the two functions. I’ve tried a lot of different ways, but nothing seems to be working.

// load calendar buttons
$(document).ready(function(){
$("#Return_Date").datepicker( { beforeShowDay: nonWorkingDates, showOn: "both",    numberOfMonths: 2, minDate: 0, maxDate: "364D", gotoCurrent: true, buttonImageOnly: true }   );
$("#Depart_Date").datepicker( { beforeShowDay: nonWorkingDates, showOn: "both", numberOfMonths: 2, minDate: 0, maxDate: "364D", gotoCurrent: true, buttonImageOnly: true    }   );
});

// load blocked days - this loads properly into the date pickers above
function nonWorkingDates(date){
// create an array for closedDates
var closedDates = [[3,22,2012], [3,25,2012], [4,15,2012], [4,24,2012], [4,25,2012]];

//loop through the list of closed Dates
for (i = 0; i < closedDates.length; i++) {      
    // if the date is found set it as disabled. January is 0, February 1, etc so a -1 is needed on the month value
    if (date.getMonth() == closedDates[i][0] - 1 && date.getDate() == closedDates[i][1] &&  date.getFullYear() == closedDates[i][2]) {
        return [false];
    }
}
return [true];
};

//load in closed dates i need the BlockedTravelDays array to pull into the date pickers. the array here loads fine
$(document).ready(function NoTravelDays() {
$("#TripApprovalDepartment").change(function() {
    var value = $.trim($("#TripApprovalDepartment").val());
    if (value.length > 0) {
        $.getJSON("../approval.cfc?method=getBlockedDays&returnFormat=json", {DeptID:value}, function(res,code) {
            // create an Array
            var BlockedTravelDays = [];
            for (var i = 0; i < res.DATA.length; i++) { 
                // store the travel days in the array
                BlockedTravelDays.push(res.DATA[i][2]);
            }; // end for loop
        }); // end JSON
    } // end if
});
});
  • 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-02T04:07:48+00:00Added an answer on June 2, 2026 at 4:07 am

    A simple solution would be just to call both function from yet a third function. This does not have the flexibility some may need, but it seems you do not need the same flexibility. So, we’d get something like this:

    $(document).ready(function()
    {
        function1();
        function2();
    }
    

    Seeing that you are already using an anonymous function, that function can just call the other function instead, giving you this:

    $(document).ready(function(){
        $("#Return_Date").datepicker( { beforeShowDay: nonWorkingDates, showOn: "both",    numberOfMonths: 2, minDate: 0, maxDate: "364D", gotoCurrent: true, buttonImageOnly: true }   );
        $("#Depart_Date").datepicker( { beforeShowDay: nonWorkingDates, showOn: "both", numberOfMonths: 2, minDate: 0, maxDate: "364D", gotoCurrent: true, buttonImageOnly: true    }   );
    
        NoTravelDays();
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote the following simple function that takes two parameters mostly coming from another
I have several functions that I wrote and I use regularly on my servers,
guys, I wrote a function to test if two inputs (a and b) have
I have a function that calls out a read or write request on a
I have a function that I use quite frequently, which allows me to write
I have a c# function that needs to write to a SQL image column.
I'd like to write a function that would have some optional code to be
I have the following functions (wrote in Visual C++ 2005) int &getInt_1() { int
We have written a large library functions whose prototypes mostly look like: void my_fun(
For a small to-be-embedded application, I wrote a few functions + struct that work

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.