I would like to select a date and insert it in the table.
For example, I select a date:
After selecting a date it is inserted in a row as shown:
This is the Javascript code:
$('input[name="allotment"]').on('apply.daterangepicker', function(ev, picker) {
var allomentDate = picker.endDate.format('DD') - picker.startDate.format('DD');
console.log(allomentDate);
console.log(picker);
/* for (i=1;i<=allomentDate;i++){
var dd = start.format('DD').toString();
console.log(dd);
var dateAllot = dd+1;
console.log(dateAllot);
var addRow = "<tr><td><input type='text' name='allomentDate[dateAllot]' readonly value=''></td>" + "<tr><td>";
}*/
});
However it's just getting started. Now, I still can not get value the startdate and enddate.
$('input[name="allotment"]').daterangepicker({
"drops": "down",
"opens": "center",
}, function (start, end, label) {
console.log("A new date selection was made: " + start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD'));
var dd = parseInt(end.format('DD')) - parseInt(start.format('DD'));
var startDate = new Date(start.format('YYYY-MM-DD'));
var endDate = new Date(end.format('YYYY-MM-DD'));
//console.log(startDate.getDate());
//console.log(endDate.getDate());
//console.log(allot);
for (i=1;i<=dd;i++){
var allot = startDate.getDate()+1;
console.log(allot);
var addRow = "<tr><td><input type='text' name='allomentDate[i]' readonly value='startDate'></td>" +
"<tr><td>";
}
});
set start.format('YYYY-MM-DD') to date and use get.Date + 1
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.