JavaScript Calendar Popup

Posted on 2009-02-10
Last Modified: 2013-11-19

I have been working on a event form for a colleague of mine that the company I work for will be hosting.  I have managed with the assistance of experts here at expert-exchange to get the form working with a fair bit of JavaScript, however I have noticed a slight issue with some script I found on the Internet which provides a JavaScript popup calendar which opens in a div.  The calendar works fine and looks great and does exactly what I want it to do.

The problem is one of my fields is date of birth and the calendar only starts from 2007 and ends at 2011.  I have looked at the JavaScript and found some reference to the start year offset and changes it from 2 to 120.  The issue with this is it displays 120 years  + and - of the current year.  This is no good for me all I wanted it to do is go back 120 years and remain 2 years + of the current year.

I have uploaded the JavaScript file and was wondering if there is anything I missing.  I would really appreciate any assistance with this as it's the last little issue I have.
Question by:john_hollings
    LVL 16

    Accepted Solution

    If you want that functionality in that attached javascript file, please change line #1289
    which contains:

    for( var yearCounter=year-this.yearSelectStartOffset; yearCounter<=year+this.yearSelectStartOffset; yearCounter++ ) {


    for( var yearCounter=year-this.yearSelectStartOffset; yearCounter<=year; yearCounter++ ) {

    and it will only show the years from the current year until the current year minus the offset.
    LVL 5

    Author Closing Comment

    Nice one, it works - thank you so much, I have been looking at this JS code for days trying to find where it applied the yearCounter.  My knowledge of JavaScript is very limited but is growing all the time thanks to you and the other experts here that keep helping.  So again many thanks for your help.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Join & Write a Comment

    This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
    Read about why website design really matters in today's demanding market.
    Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now