darren-w-
asked on
Dynamic date period
Hi,
Have a form that has a date period defined in a select drop down, at present its Fortnight, Month and 6 Month.
I have this code:
What I would like to happen is that when the selected option changes that the period defaultDate be defined in as can be returned by the function.
How can this be done?
Have a form that has a date period defined in a select drop down, at present its Fortnight, Month and 6 Month.
I have this code:
jQuery(function(){
var dfdate=function(){return calculateDate()}();
jQuery("#Enter_date").datepicker({
defaultDate: dfdate,
dateFormat: 'dd/mm/yy',
changeMonth: true,
beforeShowDay: jQuery.datepicker.noWeekends,
minDate: 0
});
})
function calculateDate(){
var freq = jQuery('#frequency option:selected').attr('label');
var twovalue;
var retString;
if(freq.indexOf(' ') >= 0){
twovalue= freq.split(' ');
}
if (freq.indexOf(' ') >= 0){
twovalue= freq.split(' ');
var freqNo = twovalue[0];
var freqPeriod = twovalue[1].charAt(0).toLowerCase();
retString = "+"+freqNo+freqPeriod
}else if(freq.toLowerCase() == "fortnight"){
retString = "+2w";
}else{
retString = "+1"+ freq.charAt(0).toLowerCase();
}
return retString;
}
What I would like to happen is that when the selected option changes that the period defaultDate be defined in as can be returned by the function.
How can this be done?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Ahh minDate makes more sense. Have you thought about what happens if they have something selected that lets them pick an early date which they then change the #frequency which means that date is invalid?
ASKER
Humm, added another question, need to do more donkey work on the date https://www.experts-exchange.com/questions/27828186/Datepicker-set-period-after-specified-time.html
ASKER
Open in new window
I was after minDate actually