![]() ![]() |
Can I get some code that will do something whenever a field on my form is changed? Since the Grease Monkey script runs when the page is loaded, how can I get it to work after the fact? |
![]() ![]() |
I believe you can create an Event Listener that will run when the field is changed, or perhaps more usefully once it loses focus (the user clicks outside the field) |
![]() ![]() |
I've tried this:
|
![]() ![]() |
We need to distinguish here between referring to a function and calling a function. Example:
var aFunction = sayhello; // referring to; notice the lack of ()
var theResult = sayhello('world'); // calling
Assuming
function aFunction () {
sayhello('world');
}
var elmLink = document.getElementById('MyFieldName');
elmLink.addEventListener("click", aFunction, true);
Alternatively, you can use an anonymous function:
var elmLink = document.getElementById('MyFieldName');
elmLink.addEventListener("click", function () { sayhello('world'); }, true);
|



