I have a small piece of code that I want to accomplish 3 things on:
- User Enters Birthday
- User is able to see current date
- When user clicks button, they are given the time elapsed between their birthday and now (i.e. current time - birthday).
The trouble I am having is that when the button is clicked all I get is NaN. I am not sure how to proceed at this point.
<li><label>Enter Your Birthday</label></li>
<li><input type="date" name="field1" id="field1"></li>
<li><label for="date">Current Date</label></li>
<script id="curDate">
var d = new Date();
document.write(d);
var bDay = new Date(document.quiz.field1);
var eTime = d - bDay;
function calcDate(eTime) {
document.write(eTime);
}
</script>
<li><input type="button" value="Click" onclick="calcDate(eTime)"></li>