I am adding date inputs with datepicker attached.
An the problem is: I pick a date in the first input and I try to pick another date in the second or third or .. inputs. Well, this last picked date shows in the first input, overwriting the already picked date, and leaves the new input blank.
Why is that? How can I solve this?
Here’s the html:
<div id="main">
<span>
<input type="text" id="mydate" name="mydate[]" class="datepicker">
</span>
</div>
<a href="#" id="addInput">Add input</a>
And here’s the js:
var datePickerOptions = {
dateFormat: 'd/m/yy',
firstDay: 1,
changeMonth: true,
changeYear: true
}
$(document).ready(function()
{
$('.datepicker').datepicker(datePickerOptions);
});
$(function() {
var scntDivA = $('#main');
var ii = $('#main span').size() + 1;
$('#addInput').live('click', function() {
$('<input type="text" id="mydate" name="mydate[]" class="datepicker"').appendTo(scntDivA);
$('.datepicker').datepicker(datePickerOptions);
ii++;
return false;
});
});
Thanks!