I am trying to get the text in a text box as the user types in it (jsfiddle playground):
Try to concatenate the event charCode to the value you get. Here is a sample of my code:
js:
function cnum(event, str) {
var a = event.charCode;
var ab = str.value + String.fromCharCode(a);
document.getElementById('demo').innerHTML = ab;
}
The value in ab
will get the latest value in the input field.