function calcPrice() { //get relevant data from form fields vanD=parseInt(document.boekform.data_DatumvanD.value,10); // ,10 argument to parse as decimal number vanM=parseInt(document.boekform.data_DatumvanM.value,10) - 1; //month starts at 0 with JS Date vanJ=parseInt(document.boekform.data_DatumvanJ.value,10); tmD=parseInt(document.boekform.data_DatumtmD.value,10); tmM=parseInt(document.boekform.data_DatumtmM.value,10) - 1; tmJ=parseInt(document.boekform.data_DatumtmJ.value,10); aantV=parseInt(document.boekform.data_Aantvolw.value,10); aantK=parseInt(document.boekform.data_AantkindG.value,10); //assign price variables, depending on the year if (vanJ==2004) { dayPrice=55; // price per day dayPriceFullWeek=50; //discount per day if more than 6 days booked }else{ dayPrice=60; //price per day dayPriceFullWeek=54; //discount per day if more than 6 days booked } extCharge=3; // price per day for persons > 2 //review data if(isNaN(aantK)) {aantK=0} if ((vanJ < 2000) && (vanJ>0)) { vanJ = vanJ+2000; document.boekform.data_DatumvanJ.value=vanJ; } if ((tmJ < 2000) && (tmJ>0)) { tmJ = tmJ+2000 document.boekform.data_DatumtmJ.value=tmJ; } if (document.boekform.data_Babybed.value=='J') { extBbed = 2; } else { extBbed = 0; } //create date variables and calculate number of days vanDatum = new Date(vanJ,vanM,vanD); tmDatum= new Date(tmJ,tmM,tmD); numDays=((tmDatum-vanDatum)/86400000); // 24*60*60*1000 (date calc gives milliseconds) numDays=numDays.toFixed(0); //some bug with date = 24-3-2006 //calculate price, number of people and total if (numDays>6) {dayPrice=dayPriceFullWeek} // discount if more than 6 days booked numPersons=aantV+aantK; if (numPersons>2) { aantExt=(numPersons-2); }else{ aantExt=0; } total=(numDays*dayPrice)+(aantExt*extCharge*numDays)+(numDays*extBbed); total=total.toFixed(2); if (!isNaN(total) && (total>0)) { document.boekform.data_Price.value=total; }else{ document.boekform.data_Price.value=''; } }