O
omidmottaghi
I need to disable/enable form elements in my form.
the code i was developed works fine in FF, but in IE, its behaviour is
very strange!!
in the form, we have a lot of checkboxes, all of them named like
"xyz_np".
in front of each checkbox, we have some fields, named "xyz"
this is my JS code.
after clicking on checkboxes:
======================================
function clicked(me, objNames){
obj = findObj(me);
for(i = 0; i < objNames.length; i++){
obj1 = findObj(objNames);
if(obj.checked==true){
obj1.disabled = false;
obj1.style.border = "1px solid #000";
obj1.style.color = "#000000";
}else{
obj1.disabled = true;
obj1.style.border = "1px solid lightgray";
obj1.style.color = "gray";
}
}
}
=======================================
at startup, on body onload event:
=======================================
function start(){
obj = findObj("search");
for(i = 0; i < obj.elements.length; i++){
if(obj.elements.name.indexOf('_np')==-1 &&
obj.elements.name.indexOf('submit')==-1){
obj.elements.disabled = true;
obj.elements.style.border = "1px solid lightgray";
obj.elements.style.color = "gray";
}
}
}
NOTE: findObj() is Macromedia findObj function. it should return an
element resource.
this code, in IE, cannot disable a field **UNTIL** you typed some
characters in that field, before disabling!!!!
i used FF1.5b2 and IE6SP1.
the code i was developed works fine in FF, but in IE, its behaviour is
very strange!!
in the form, we have a lot of checkboxes, all of them named like
"xyz_np".
in front of each checkbox, we have some fields, named "xyz"
this is my JS code.
after clicking on checkboxes:
======================================
function clicked(me, objNames){
obj = findObj(me);
for(i = 0; i < objNames.length; i++){
obj1 = findObj(objNames);
if(obj.checked==true){
obj1.disabled = false;
obj1.style.border = "1px solid #000";
obj1.style.color = "#000000";
}else{
obj1.disabled = true;
obj1.style.border = "1px solid lightgray";
obj1.style.color = "gray";
}
}
}
=======================================
at startup, on body onload event:
=======================================
function start(){
obj = findObj("search");
for(i = 0; i < obj.elements.length; i++){
if(obj.elements.name.indexOf('_np')==-1 &&
obj.elements.name.indexOf('submit')==-1){
obj.elements.disabled = true;
obj.elements.style.border = "1px solid lightgray";
obj.elements.style.color = "gray";
}
}
}
NOTE: findObj() is Macromedia findObj function. it should return an
element resource.
this code, in IE, cannot disable a field **UNTIL** you typed some
characters in that field, before disabling!!!!
i used FF1.5b2 and IE6SP1.