...

View Full Version : Event function tutorials.



Scriptdaemon
04-30-2007, 01:06 AM
I've tried looking for tutorials on how to make a function that executes every time a specific event happens, (see below for an example) but I can't quite find the correct wording to find a tutorial that would show me how these really work. I want to do something like this that would execute every time a key is pressed on an input field. Anyone understand what I want enough to know of a site that will help me with this?

Example:




xhr.onReadyStateChange = function() {
CODE HERE
};

david_kw
04-30-2007, 02:14 AM
For everytime a key is hit would look something like this



<input type="text" id="t" name="t" />

<script type="text/javascript">
document.getElementById("t").onkeypress = function () {
alert("a key was hit");
};
</script>


david_kw

1212jtraceur
04-30-2007, 02:37 AM
http://www.google.com/search?q=javascript+event

Scriptdaemon
04-30-2007, 08:01 PM
For everytime a key is hit would look something like this



<input type="text" id="t" name="t" />

<script type="text/javascript">
document.getElementById("t").onkeypress = function () {
alert("a key was hit");
};
</script>


david_kw

Thanks. See, I tried that in my code before I asked and it didn't work, which means I had something wrong with the other part of my code for it so now I know which part of it made it not work.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum