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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T14:38:22+00:00 2026-05-14T14:38:22+00:00

I have a jquery datepicker script and what I want to do is to

  • 0

I have a jquery datepicker script and what I want to do is to change “minDate: 10” value by a select box.
if the first option is selected the minDate:10 , if the second option is selected then minDate:20 etc…

Is it going to update the datepicker in real time every time I select a different selection?

Thanks in advance!

$(function() {
               $('#hotel').change(function() {
                 // assign the value to a variable, so you can test to see if it is working
                 var selectVal = $('#hotel :selected').val();
                 if( selectVal == "hotel_c" ) {
                var date = 10;
                 }
                 if( selectVal == "hotel_a" ) {
                var date = 15;
                 }
                 if( selectVal == "hotel_b" ) {
                var date = 6;
                 }
                });
        var dates = $('#from, #to').datepicker({
            defaultDate: "+1w",
            changeMonth: true,
            dateFormat: 'yy-m-d',
            minDate: 10,
            numberOfMonths: 3,
            onSelect: function(selectedDate) {
                var option = this.id == "from" ? "minDate" : "maxDate";
                var instance = $(this).data("datepicker");
                var date = $.datepicker.parseDate(instance.settings.dateFormat || $.datepicker._defaults.dateFormat, selectedDate, instance.settings);
                dates.not(this).datepicker("option", option, date);
            }
        });
    });
  • 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-14T14:38:23+00:00Added an answer on May 14, 2026 at 2:38 pm

    You can write your change handler like this:

    var hotelMap = { hotel_a: 15, hotel_b: 6, hotel_c: 10 };
    $('#hotel').change(function() {
      var selectVal = $('#hotel :selected').val();
      $("#from, #to").datepicker("option", "minDate", hotelMap[selectVal]);
    });
    

    This has 2 changes, we’re calling the .datepicker('option', 'minDate', val) method, and we’re using an object to map the date ranges to clean it up a bit. This will only let you select a date 15, 6, or 10 days out depending on your selection.

    You can see this with the rest of your code working here

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

Sidebar

Related Questions

I have used Jquery UI DatePicker for the option in my form to select
I have made a jQuery UI Datepicker script as below to select only Weekends.
I have this jQuery datepicker code that initially set the minDate of the datepicker.
i have a script. jQuery datepicker with url's on database. <script> $(function() { $('#datepicker').datepicker({
I have this program and i want to add a jquery datepicker on it,
http://docs.jquery.com/UI/Datepicker i want to have a link with the choosen date to click at
I have recently encountered a problem in IE, using the jQuery UI datepicker script:
well im using this script right here: http://www.kelvinluck.com/assets/jquery/datePicker/v2/demo/ and I have a multiMonth plugin
I have a jquery datepicker which is renders the current date by default as
I have a JQuery datepicker that outputs the number of nights in a span

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.