Reputation: 61
html code
<p id="value"></p>
Date to Travel <input type="date" id="date" name="date" />
javascript code
it looks clean code to me, don't know whats the problem in it
window.onload = function() {
document.getElementById("date").addEventListener("keyup", keyisup, false);
}
function keyisup() {
document.getElementById("value").innerHTML = date;
}
Upvotes: 1
Views: 4312
Reputation: 61
i think this will work
document.getElementById("value").innerHTML = document.getElementById("date").value;
this is answer which i found error by my own
thanks for all
Upvotes: 0
Reputation: 847
DId you try
function keyisup()
{
document.getElementById("value").innerHTML = $('#date').val();
}
in case you are referring to input with id date
Upvotes: 0
Reputation: 193261
It shows [object HTMLInputElement]
because you told it to do so.
document.getElementById("value").innerHTML = date;
In this code you are setting innerHTML to date
, however you are not defining it anywhere. So what happens is that it takes global value date
which is going to be a reference to <input type="date" id="date" name="date" />
, because browser exposes HTML elements as global references if they have id
attribute.
Possible solution could be:
function keyisup(e) {
document.getElementById("value").innerHTML = e.target.value; // or this.value
}
Upvotes: 1