I tied the event onchange to my textbox control:
var tbValue = document.getElementById("tbValue");
tbValue.onchange = function () {
var tbSelText = document.getElementById("selectText");
if (tbValue.value == null) {
tbSelText.value.replace("sada", "");
}
else {
tbSelText.value.replace("sada", "sada" + tbValue.value + "'");
}
}
When I change tbValue (it’s my textbox control with onchange event) tbSelText must change at the same time. But it doesn’t.
What I did wrong?
I am guessing that you’re expecting the
onchangeevent to fire while typing, which is not going to happen.The
onchangeevent only fires when the textbox losses focus (in other words, it blurs) AND if the content has changed. See this MSDN for information…If you want an event while typing you should look at one of the
onkeydown,onkeypressoronkeydownevents.