I am trying to make the Jquery-UI datepicker have only 1 date available per month, which is the 1st of every month, when selected the selected date + X days, should be copied into another text input field.
Additionally, the value of days to be added changes with what has been selected in the dropdown.
Fiddle what I have so far: http://jsfiddle.net/8y4Bf/
Code from fiddle:
Html
<div>
<label>Select an Option:</label>
<select id="select1">
<option value="" disabled="disabled" selected="selected">Select an option</option>
<option value="1">Option 1</option>
<option value="2">Option 2</option>
</select>
</div>
<br /><br />
<div>
<label>Start Date:</label>
<input type="text" id="startdate" />
<br /><br />
<label>End Date:</label>
<input type="text" id="enddate" />
</div>
Jquery
$('#select1').change(function() {
$('#startdate, #enddate').val("");
if ($('#select1').val() == '1') {
$('#startdate').datepicker({
showButtonPanel: true,
closeText: 'Close',
dateFormat: "mm/dd/yy",
onSelect: function(selected) {
if (this.id == 'startdate') {
// Parameters 1 day only & also copy result into enddate + 5 days
}
}
});
}
else if ($('#select1').val() == '2') {
$('#startdate').datepicker({
showButtonPanel: true,
closeText: 'Close',
dateFormat: "mm/dd/yy",
onSelect: function(selected) {
if (this.id == 'startdate') {
// Parameters 1 day only & also copy result into enddate + 7 days
}
}
});
}
});
I have read the documentation at http://jqueryui.com/datepicker/#min-max but can't figure out how do I make only the 1st of every month available.
And do I have to fetch the value of #startdate
again, add the days and then paste it into #enddate
or is that value saved somewhere so I can go from there ?