HighDots Forums  

Re: Can't test disabled property

Javascript JavaScript language (comp.lang.javascript)


Discuss Re: Can't test disabled property in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
knf
 
Posts: n/a

Default Re: Can't test disabled property - 07-02-2003 , 01:59 PM






This was the solution I received:
Quote:
If you have <input> elements with the same name then the browser
document object model reflects them as an array thus you need to
check
f.myoption[0].disabled
f.myoption[1].disabled
That worked although only one of the options show as disabled although
both are in their input tags. For now I am using the above and
testing if either [0] or [1] is disabled.

Thanks.

kris10 (AT) alum (DOT) mit.edu (knf) wrote in message news:<82594fc5.0307020647.4d297de4 (AT) posting (DOT) google.com>...
Quote:
I have a page in which sometimes radio buttons are disabled although
this is not the normal case. On the radio buttons that may be
disabled, I have javascript validation ensuring other fields are
filled out when they are not disabled. But I do not want this
validation to occur when the radio buttons are disabled.

The radio buttons look like this:
input type="radio" name="myoption" value="0" >Option 1
input type="radio" name="myoption" value="1" checked>Option 2

and the form has the onsubmit validation:

form name="myForm" method="post" action="xxx.asp" onSubmit="return
checkDetails(this)"


And the javascript for checkDetails looks like this: (f is the input
parameter i.e "this" or the form)

if (f.blnBTDialin == null) {
return true;
}
else if (f.myoption.disabled == true) {
return true;
}
else if Boolean(<%=aspvalue%>) && f.myoption[1].checked &&
f.detail1.checked ) {
alert ("Sorry, blah blah blah.")
return false;
}
else {
if (f.myoption[1].checked && f.detail1.checked == true &&
f.detail2.checked == false) {
alert ("You must select detail2.")
return false;
}
}

I have two problems, at first I did not have the line containing
(f.myoption.disabled == true) because I thought the remaining
conditions would fail if the field was disabled. But if the field is
disabled and even if myOption[0] is selected, the code falls through
to the "You must select detail2" clause.
So I added the test on the disabled property, but this property always
comes up as undefined, whether the radio buttons are disabled or not.
This is the case also if I try typeof(f.myoption.disabled)

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.