bfausti
10-15-2003, 11:35 PM
I am fairly new to javascript and have a little problem. Here's my code:
function disElement(element1,element2) {
el = document.frmFD.element1;
for ( i=0; i < el.length; i++ ) {
if ( el[i].checked ) {
if(el[i].value == "Yes"){
document.frmFD.element2.disabled = false;
}
if(el[i].value == "No"){
document.frmFD.element2.disabled = true;
}
if(el[i].value == "Unsure"){
document.frmFD.element2.disabled = true;
}
}
}
}
</script>
I have a form with 3 radio buttons and a input box (text box) i am trying to disable or enable this box judged on what radio button the user clicks. My problem is I am trying to make this function as generic as possible so I can use it else where (As good programmers should do:)) But it doesn't seem to be working.
Can anyone tell me what is wrong with my code. The error is "el.length is null or not an object."
function disElement(element1,element2) {
el = document.frmFD.element1;
for ( i=0; i < el.length; i++ ) {
if ( el[i].checked ) {
if(el[i].value == "Yes"){
document.frmFD.element2.disabled = false;
}
if(el[i].value == "No"){
document.frmFD.element2.disabled = true;
}
if(el[i].value == "Unsure"){
document.frmFD.element2.disabled = true;
}
}
}
}
</script>
I have a form with 3 radio buttons and a input box (text box) i am trying to disable or enable this box judged on what radio button the user clicks. My problem is I am trying to make this function as generic as possible so I can use it else where (As good programmers should do:)) But it doesn't seem to be working.
Can anyone tell me what is wrong with my code. The error is "el.length is null or not an object."