Link to home
Start Free TrialLog in
Avatar of bjh497
bjh497

asked on

jqery ui datepicker :- passing variables

Having problems with two datepickers one of which the year dropdown caries the year from the other as it's minimum for year dropdown value.

The following code is executed, the onclose functions are called successfully but the global variable "ch_from_year" is not being altered by the onclose function although it is being used successfully within that function (i.e. it sets the right date for that datepicker but it does not seem to carry the value to the gloabal variable.)
var ch_from_year = '1940';
$(function() {
	$('#ch_from_date').datepicker({
		showOn: 'button',
		buttonImage: '../css/images/calendar.gif',
		buttonImageOnly: true,
		changeMonth: true,
		changeYear: true,
		minDate: new Date(1929, 1 - 1, 1),
		beforeShowDay: hideDays,
	 	yearRange: '1929:2010',
	 		dateFormat: 'mm-yy',
	        onClose: function(dateText, inst) { 
	            var month = $("#ui-datepicker-div .ui-datepicker-month :selected").val();
	            ch_from_year = $("#ui-datepicker-div .ui-datepicker-year :selected").val();
	            $(this).datepicker('setDate', new Date(ch_from_year, month, 1));
	        		        }
    	 	
	});
	
	});

$(function() {
	$('#ch_to_date').datepicker({
		showOn: 'button',
		buttonImage: '../css/images/calendar.gif',
		buttonImageOnly: true,
		changeMonth: true,
		changeYear: true,
		minDate: new Date(ch_from_year, 1 - 1, 1),
		beforeShowDay: hideDays,
	 	yearRange: '1929:2010',
	 		dateFormat: 'mm-yy',
	        onClose: function(dateText, inst) { 
	            var to_month = $("#ui-datepicker-div .ui-datepicker-month :selected").val();
	            var to_year = $("#ui-datepicker-div .ui-datepicker-year :selected").val();
	            $(this).datepicker('setDate', new Date(to_year, to_month, 1));
	        }
			 	
	});

	});

Open in new window


Advice appreciated.

ASKER CERTIFIED SOLUTION
Avatar of mhmr
mhmr
Flag of United Arab Emirates image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
the changes is on lines "15" "16" "17"
just to be clear


Avatar of bjh497
bjh497

ASKER

sorry we had already fixed it.
Avatar of bjh497

ASKER

we solved it internally but htis solution was nearly their.