0
I need to take the current date and add days according to the selected
function calcular(){
var valor1 = parseInt(document.getElementById('dias1').value);
var valor2 = parseInt(document.getElementById('dias2').value);
var valor3 = parseInt(document.getElementById('dias3').value);
document.getElementById('diassomado').value = valor1 + valor2 + valor3;
}
function RetornaDataHoraAtual(){
var dNow = new Date();
var localdate = dNow.getDate() + '/' + (dNow.getMonth()+1) + '/' + dNow.getFullYear();
document.getElementById('dataatual').value = localdate;
return localdate;
}
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Documento sem título</title>
</head>
<body>
<div class="row">
<label>Dias 1</label>
<select id="dias1" >
<option value="">Selecione</option>
<option value="5">5</option>
<option value="10">10</option>
</select>
<label>Dias 2</label>
<select id="dias2" >
<option value="">Selecione</option>
<option value="5">5</option>
<option value="20">20</option>
</select>
<label>Dias 3</label>
<select id="dias3" >
<option value="">Selecione</option>
<option value="5">5</option>
<option value="30">30</option>
</select>
</div>
<div class="row">
<label>Dias</label>
<input type="text" id="diassomado" ><br>
<label>Data Atual</label>
<input type="text" id="dataatual" ><br>
<label>Data Somada</label>
<input type="text" id="datasomada" >
</div>
<input type="button" onClick="calcular(), RetornaDataHoraAtual()" value="Gerar">
</body>
</html>
Example 5 days current date 10/05/2018 Upshot 15/05/2018
Possible duplicate of How to add date, from a Date and Number of days typed by the user
– Sam