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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:44:19+00:00 2026-05-23T11:44:19+00:00

I´m trying to add some functionality to a form with JQuery UI´s Datepicker. When

  • 0

I´m trying to add some functionality to a form with JQuery UI´s Datepicker.

When a user selects the arrival date (onSelect), a few things should happen:

  1. Update the departure to 3 days after the arrival date (This works now :))
  2. Split the departure date in 3 and add each part to an input field (see arrival date example in Fiddle)
  3. When the arrival-datepicker closes (onClose), the departure-datepicker should open automatically, defaulting to the date selected in point 1 (example: http://www.kayak.es )

I managed to get point 1 to work, but I´m a bit lost with the other features. If anyone can show me how to do this or get me on the right track that would be really great! I´m still a beginner but learning fast.

Here´s a Fiddle of what I have now: http://jsfiddle.net/mattvic/B6Kax/13/

  • 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-05-23T11:44:19+00:00Added an answer on May 23, 2026 at 11:44 am

    Split the departure date in 3 and add
    each part to an input field

    Looks like you already have the code written for this in the onSelect handler of the destination datepicker. Unfortunately, it looks like setDate does not trigger that event, and you cannot trigger it manually. What I would recommend is breaking that code out into a separate function that you can call from both places:

    function splitDepartureDate(dateText) {
        var depSplit = dateText.split("-", 3);
        $('#alt-vertrek-d').val(depSplit[0]);
        $('#alt-vertrek-m').val(depSplit[1]);
        $('#alt-vertrek-y').val(depSplit[2]);
    }
    

    Then change your departure datepicker onSelect handler to point to that function:

    $('#vertrek').datepicker({
    
        // Prevent selecting departure date before arrival:
        beforeShow: customRange,
        onSelect: splitDepartureDate
    });
    

    Lastly, call that function from your arrival’s onSelect event handler:

    /* snip: */
    
    // Populate departure date field 
    var nextDayDate = $('#aankomst').datepicker('getDate', '+3d');
    nextDayDate.setDate(nextDayDate.getDate() + 3);
    $('#vertrek').datepicker('setDate', nextDayDate);
    
    // Manually call splitDepartureDate
    splitDepartureDate($("#vertrek").val());
    

    When the arrival-datepicker closes
    (onClose), the departure-datepicker
    should open automatically, defaulting
    to the date selected in point 1

    This is just a matter of using the onClose event handler:

    onClose: function() {
        $("#vertrek").datepicker("show");
    }
    

    Here’s your updated example: http://jsfiddle.net/zXMke/

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

Sidebar

Related Questions

I have a question about some functionality I'm trying to add to my jQuery
I am trying to add some existing functionality to a site that uses jQuery
So I'm trying to add some ability to my project to allow user-defined properties
I'm trying to add some functionality to our code base by using tied scalars.
I'm currently trying to add some testing functionality into our builds, and in order
I'm trying to add some jQuery stuff to Gmail using a GreaseMonkey script. Adding
I'm trying to add some functionality from a plugin I have made into a
I am trying to add some functionality to a page I have inherited, but
I am trying to add some functionality to my posts/new page when it loads,
I am trying to add some basic dynamic functionality to a web page. How

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.