...

View Full Version : event triger when a html inputField has a value set through javascript



gregd101
06-26-2012, 04:50 PM
Is there a way to have an event triger when a html inputField has a value set through javascript?

So for example



<input class='inputField' size="20" type='text' name='num1' onchange="doIt3();" > </td> <br>

function doIt3() {
alert("here") ;
}

function doIt2() {
var hn = document.getElementById("num1");
hn.value = "aaaa";
}



doIt2 runs it changes the value of num1. However the onchange=doIt3() will not trigger until the user goes into the field, manually changes the value and then leaves the field.

Is there an event I can trigger when the value automatically changes?

thanks

DaveyErwin
06-26-2012, 05:12 PM
function doIt2() {
var hn = document.getElementById("num1");
hn.value = "aaaa";
doIt3();
}

gregd101
06-26-2012, 06:03 PM
thank you.
However this is just a simple example.
In reality, I would like the inputField to pass itself into the function.
Then I can generically act on any control on my page.
any other ideas?

thanks

Dormilich
06-27-2012, 07:05 AM
event handlers assigned through JavaScript can refer to the element via the keyword this.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum