How to do this using jQuery
i have a select like
<select id="Plan_Id" name="Plan_Id">
<option value="30">Month</option>
<option value="365">Annual</option>
</select>
then i have a input
<input name="date" id="date_picker" type="text" class="text date_picker" />
so based on the option i select i want to get the date today + value and show on the input was
m-d-Y.
so if today is january 07 and i select 30 -> month
my input will be populated with 02-06-2012
Rather than general googling, you want to look specifically at a JavaScript reference about the Date object and at the jQuery UI datepicker reference. Between the two you’ll have all the information you’ll need to work this out. But since I already happen to know the answer (or an answer)…
Given a JavaScript date object:
You can add n days to it by setting the day-of-the-month to the current value plus n – the month and/or year will be automatically adjusted as appropriate. So:
Put together with the jQuery datepicker “setDate” method:
Demo: http://jsfiddle.net/WUdWs/1/