I am trying to create two different sets of settings for datepicker(http://keith-wood.name/datepick.html) when the user picks different radiobuttons in a group.
Here's my code:
$("input[name='shipping_time_english']").change(function(){
datepicker();
});
function datepicker() {
if ($("input[name='shipping_time_english']:checked").val() == '1-3 work days') {
alert('1-3 days selected');
var firstDay = '+1';
var lastDay = '+3';
} else if ($("input[name='shipping_time_english']:checked").val() == '4-8 work days') {
alert('4-8 days selected');
var firstDay = '+4';
var lastDay = '+8';
}
$("#rush_needed_by_english").datepick({
minDate: firstDay,
maxDate: lastDay
});
} //end datepicker function
I know the change event is working, because the alerts are alerting each time I change the value of the radiobuttons. For some reason, the settings on the datepicker are whatever the first value on the radiobuttons is that I select. As soon as I change the radiobutton value again, the settings on the datepick don't change as I would like.
Why can I not update settings on datepicker using change in jQuery?