invulformulier-Demo/formulier/assets/js/datecalc.js

33 lines
1.7 KiB
JavaScript
Executable File

function date() {
var table = "<table class=\"tableverhuur\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n" +
" <h1>Toeslagen</h1>\n" +
"<p>Er is een toeslag per nacht verschuldigd voor ieder verblijvend persoon. Dit is ongeacht de leeftijd. Geef hier het aantal personen per nacht op.</p>" +
" <tr><th>Nacht</th><th>Aantal personen</th> <th>Kosten</th><th>Totaal</th></tr>";
var startDate = new moment(document.getElementById("datumaankomst").value,'DD-MM-YYYY',true);
var endDate = new moment(document.getElementById("datumvertrek").value,'DD-MM-YYYY',true);
moment.updateLocale('nl', {
weekdays : [
"Zondag", "Maandag", "Dinsdag", "Woensdag", "Donderdag", "Vrijdag", "Zaterdag"
]
});
dateArr = [];
while (endDate > startDate || startDate.format('D') === endDate.format('D')) {
dateArr.push(startDate.format('dddd DD-MM-YYYY'));
startDate.add(1,'day');
}
for (i = 0; i < (dateArr.length - 1); i++) {
table += (
"<tr><td class='eenvierde'>" + dateArr[i]+ "</td>" +
"<td><input type=\"number\" name=\"aantalpers[]\" id=\"aantalpers["+i+"]\" value='' max='20' required autocomplete='off' oninput=\"calculateb("+i+");\"></td>" +
" <td> <center>x &euro;5,50</center> </td> " +
"<td><input type=\"text\" name=\"totaalpers[]\" id=\"totaalpers["+i+"]\" placeholder='0' required readonly autocomplete='off'></td>" +
"<td><input type=\"hidden\" name=\"datearr[]\" id=\"datearr["+i+"]\" value=\"" + dateArr[i] + "\"></td>" +
"</tr>");
}
table += ("</table>");
document.getElementById("formuliergen").innerHTML = table
}