Listing every date between two dates in input fields Using the following HTML:

&lt;input type="date" value="2015-07-26" name="startdate"&gt;
&lt;input type="date" value="2015-07-29" name="enddate"&gt;


First, the JS calculates the number of days between two dates:

var oneDay = 24*60*60*1000; // hours*minutes*seconds*milliseconds
var start = document.querySelector('[name="startdate"]').value;
var end = document.querySelector('[name="enddate"]').value;
var firstDate = new Date(start);
var secondDate = new Date(end);
var diffDays = Math.round(Math.abs((firstDate.getTime() - secondDate.getTime())/(oneDay)));


↑ startdate is the name of the first input field and enddate is the name of the second field.

Date.prototype.addDays = function(diffDays) {
    var dat = new Date(this.valueOf());
    dat.setDate(dat.getDate() + diffDays);
    return dat;
};

function getDates(startDate, stopDate) {
    var dateArray = [];
    var currentDate = startDate;
    while (currentDate &lt;= stopDate) {
        dateArray.push(currentDate);
        currentDate = currentDate.addDays(1);
    }
    return dateArray;
}

var dateArray = getDates(new Date(start), (new Date(start)).addDays(diffDays));


↑ That is the part of the script I'm not really contented with, because I can imagine that the code could have been written simpler.

for (i = 0; i &lt; dateArray.length; i++) {
    var input = document.createElement('input');
    var br = document.createElement("br");
    input.setAttribute("value", dateArray[i]);
    input.setAttribute("type", "date");
    document.body.appendChild(input);
    document.body.appendChild(br);
}


↑ Finally, it'll create for each day (between two dates) an input field, plus an linebreak after each input.

By the way, it would be nice to use the date format "DD.MM.YYYY", instead of "YYYY-MM-DD".



// Calculate number of days between two dates
var oneDay = 24*60*60*1000; // hours*minutes*seconds*milliseconds
var start = document.querySelector('[name="startdate"]').value;
var end = document.querySelector('[name="enddate"]').value;
var firstDate = new Date(start);
var secondDate = new Date(end);
var diffDays = Math.round(Math.abs((firstDate.getTime() - secondDate.getTime())/(oneDay)));

Date.prototype.addDays = function(diffDays) {
   var dat = new Date(this.valueOf());
   dat.setDate(dat.getDate() + diffDays);
   return dat;
};

function getDates(startDate, stopDate) {
    var dateArray = [];
    var currentDate = startDate;
    while (currentDate &lt;= stopDate) {
        dateArray.push(currentDate);
        currentDate = currentDate.addDays(1);
    }
    return dateArray;
}

var dateArray = getDates(new Date(start), (new Date(start)).addDays(diffDays));

// create input fields (for each date one field)
for (i = 0; i &lt; dateArray.length; i++) {
    var input = document.createElement('input');
    var br = document.createElement("br");
    input.setAttribute("value", dateArray[i]);
    input.setAttribute("type", "date");
    document.body.appendChild(input);
    document.body.appendChild(br); // linebreak after each input field
}
&lt;input type="text" value="2015-07-26" name="startdate"&gt;
&lt;input type="text" value="2015-07-29" name="enddate"&gt;
&lt;br&gt;&lt;br&gt;
I wouldn't bother with calculating the difference - especially as it's not actually used for anything.

Instead I'd just do this:

var start = new Date(document.querySelector('[name="startdate"]').value),
    end = new Date(document.querySelector('[name="enddate"]').value),
    year = start.getFullYear(),
    month = start.getMonth()
    day = start.getDate(),
    dates = [start];

while(dates[dates.length-1] &lt; end) {
  dates.push(new Date(year, month, ++day));
}


That'll give you a dates array beginning with the start date and continuing up to and including the end date.

From there, it's pretty much the same as now: Create and append input elements. I'm not sure I like the &lt;br&gt;, though. I imagine it's mostly for layout purposes, in which case I'm sure you could handle it better in CSS.

As for the date formatting, I don't know of a way to change that. Browser support for the date-type input is very poor so just be glad if you can use it at all. But since it's not widely supported, you'll probably want to use a cross-browser widget anyway, and in that case you'll likely have options for formatting the date.