![]() Topic awaiting preservation: Setting onChange in IE via JS (Page 1 of 1) |
|
|---|---|
|
Maniac (V) Mad Scientist From: Rochester, New York, USA |
posted 07-26-2005 23:33
I am again having onChange issues. code: function setGridOnChange(){
var form = document.forms[0];
var pattern = /(\w+\.\d+)\.(\w+)/
for(i = 0; i < form.elements.length; i++){
var input = form.elements[i];
if(input.id.match(pattern) && pattern.exec(input.id)[2] != 'rowstate'){
input.setAttribute("onchange","valueChanged(this)");
}
}
}
|
|
Nervous Wreck (II) Inmate From: Deep in a cave |
posted 07-26-2005 23:50
You probably need to attach the even to get it to work in IE: |
|
Maniac (V) Mad Scientist From: Rochester, New York, USA |
posted 07-26-2005 23:55
I googled some more and found that! Thank you. code: function setGridOnChange(){
var form = document.forms[0];
var pattern = /(\w+\.\d+)\.(\w+)/
for(i = 0; i < form.elements.length; i++){
var input = form.elements[i];
if(input.id.match(pattern) && pattern.exec(input.id)[2] != 'rowstate'){
input.onchange = "valueChanged(this)";
var onChangeHandler = new Function(input.onchange);
if(input.addEventListener){
input.addEventListener('change',onChangeHandler, false);
} else if (input.attachEvent) {
input.attachEvent('onchange',onChangeHandler);
}
}
}
}
|
|
Maniac (V) Mad Scientist From: Rochester, New York, USA |
posted 07-27-2005 00:03
I did a bit of a work around. Instead of using 'this' I have passed in the input.id and then I am calling document.getElementById() on the supplied value. |