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

  • Home
  • SEARCH
  • 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 8743827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:44:48+00:00 2026-06-13T11:44:48+00:00

Thanks to techfoobar, I have a datepicker with a synchronised input field and a

  • 0

Thanks to techfoobar, I have a datepicker with a synchronised input field and a select list.

However, when I have changed the format of the date to “yy-mm-dd”, it stopped working. A change in the select list triggers the change in the input, but clicking the datepicker won’t update the select list.

Here is the script:

$(function() {
        $('#selectedDatepicker').datepicker({
        dateFormat: "yy-mm-dd",
    beforeShow: readSelected, onSelect: updateSelected,
    minDate: new Date(2013, 1 - 1, 1), maxDate: new Date(2013, 06 - 1, 31),
    numberOfMonths: 3,
    showButtonPanel: true,
    showOn: 'both', buttonImageOnly: true, buttonImage: 'http://jqueryui.com/resources/demos/datepicker/images/calendar.gif'});

// Prepare to show a date picker linked to three select controls
function readSelected() {
    $('#selectedDatepicker').val($('#selectYear').val() + '-' +
        $('#selectDay').val());
    return {};
}

// Update three select controls to match a date picker selection
function updateSelected() {
    var date1 = $(this).val();

    console.log(date1.substring(3, 5));
    console.log(date1.substring(6, 10));

    $('#selectDay').val(date1.substring(3, 5));
    $('#selectYear').val(date1.substring(6, 10));
}

    $('select').change(readSelected);

    });

This is the HTML code:

<select id="selectDay">
<option value="01">1</option>
<option value="02">2</option>
<option value="03">3</option>
<option value="04">4</option>
...
</select>
<select id="selectYear">
<option value="2013-01">January 2013</option>
<option value="2013-02">February 2013</option>
<option value="2013-03">March 2013</option>
<option value="2013-04">April 2013</option>
<option value="2013-05">May 2013</option>
<option value="2013-06">June 2013</option>
</select>
<p>Date: <input type="text" id="selectedDatepicker" /></p>

You can check the fiddle here:

http://jsfiddle.net/xKXZm/8/

Where does this problem come from? Both of the fields have the same format set.

  • 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-13T11:44:49+00:00Added an answer on June 13, 2026 at 11:44 am

    The value you are trying to select in the select element does not exist, because the substring yields a different value than it originally did. You need to adjust your substr accordingly.

    function updateSelected() {
        var date1 = $(this).val();
    
        console.log(date1.substring(8));
        console.log(date1.substring(0, 4));
    
        $('#selectDay').val(date1.substring(8));
        $('#selectYear').val(date1.substring(0, 7));
    }
    

    jsfiddle

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

Sidebar

Related Questions

Thanks for reading this. I have no idea why this is throwing a NullReferenceException
Thanks to some help I received yesterday I've got some dynamic summing working on
Thanks in advance for your help. I have a need within an application to
Thanks for reading. I have done a search, read multiple posts (lost count) and
Thanks to help I got here - I have the following code in my
Thanks in advance for any help. I have a sliding div with jquery .animate,
Thanks for your time everyone. I'm working with C# .Net 4.0 and Visual Studio
Thanks in advance. I have entered the info in itunesconnect and get the app
Thanks to the help of some most excellent members on here I have learned
thanks to the help of some of you i have this: Ext.define('PersistantSelectionGridPanel', { extend:

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.