troubleshooting Question

jQuery Date picker problem

Avatar of jset_expert
jset_expertFlag for Australia asked on
1 Comment1 Solution4119 ViewsLast Modified:
Hi, I have the successfully implemented the jQuery date picker into my PHP site.

I have drop-down lists for, date , month and year.

I grabbed some code of this site,

The problem is the dates only go back to 2005. I am using this for birthday, so it needs to go back to 1900

I have updated my list for years like so;

            <select name="y" id="y" style="width: 60px">
            for ( $counter = 2008; $counter >= 1900; $counter -= 1) {
                  echo "<option value='$counter'>$counter</option>";

I have tried to edit the following code but with no success, (I changed the 2005 dates to 1900)

The year it now posts is completely out of whack!

Can anyone help me out.

<!-- date picker script -->
<script type="text/javascript" charset="utf-8">
		// initialise the "Select date" link
				// associate the link with a date picker
				// when the link is clicked display the date picker
					return false;
				// when a date is selected update the SELECTs
				function(e, selectedDate, $td, state)
				function(e, selected)
		var updateSelects = function (selectedDate)
			selectedDate = new Date(selectedDate);
			var d = selectedDate.getDate();
			var m = selectedDate.getMonth();
			var y = selectedDate.getFullYear();
			($('#d')[0]).selectedIndex = d - 1;
			($('#m')[0]).selectedIndex = m;
			($('#y')[0]).selectedIndex = y - 1900;
		// listen for when the selects are changed and update the picker
		$('#d, #m, #y')
					var d = new Date(
		// default the position of the selects to today
		var today = new Date();
		($('#d')[0]).selectedIndex = today.getDate() - 1;
		($('#m')[0]).selectedIndex = today.getMonth();
		($('#y')[0]).selectedIndex = today.getFullYear() - 1900;
		// and update the datePicker to reflect it...
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 1 Comment.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros