'small page for answer
I need to create a page where user can see answer after he picks a date, program add 2 months and show date. Right now it's working like "alert" i don't know how create program which write answer under calendar
<body>
<input type="date" name="date" id="date"
onchange="var chooseDate = new Date(this.value);
chooseDate.setDate(chooseDate.getUTCDate() + 60);
var futureDate = chooseDate.getFullYear() + '-' + ('0' + (chooseDate.getMonth() + 1)).slice(-2) + '-' + ('0' + (chooseDate.getDate())).slice(-2);
alert('Dateadd ' + futureDate);" />
</body>
Solution 1:[1]
The field has a property called value. You can write the output of your calculation to the value field to set the value seen in the date-field.
Check out the documentation of input:
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/date
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Xtroce |
