Click to See Complete Forum and Search --> : the disabled attribute in XHTML [resolved]
Acidic
Sep 2nd, 2004, 02:41 PM
I've used JS to change the disabled attribute quite a bit. I use disabled="disabled" to disable something and disabled="" to enable it. I found that MSDN (http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/disabled_0.asp?frame=true) says you should use true/false, but then this page (http://www.w3.org/People/mimasa/test/xhtml/media-types/test4.html) on the W3C says you should use what I use for dissabling them. I tried setting disabled="" and disabled="false" and disabled="enabled". None of these were allowed by XHTML1.0 Strict or transitional. What's the right way of doing this? I realise that you can simple leave out the attribute, but when changing it wil JS what should you set it to?
ober0330
Sep 2nd, 2004, 03:01 PM
Well... I'd say if you're expecting it to work in IE, better go by what MSDN says. Now... if you want to do it the RIGHT way... then do what the standard says. ;)
riis
Sep 2nd, 2004, 03:57 PM
Omit the disabled attribute entirely if you don't want to have the textbox disabled. Delete the attribute with JavaScript (removeAttribute).
In "old" HTML you only had to type "disabled" if you wanted to disable a form control. I've understood that for XHTML all those single-worded statements should be expanded to ' statement="statement" ', and if it doesn't occur, then just leave it out.
riis
Sep 2nd, 2004, 03:59 PM
If this doesn't work for IE, I'm afraid you need to include some object detection to determine in which browser your code is running... :(
Acidic
Sep 2nd, 2004, 04:02 PM
sorry for not clearing up. both the old style, the true/false method and "disabled"/"" work in all browsers I've tried. I was just looking for how to do it following the standards, thanks for the reminder on removeAttribute, I had totally forgotten about that one as I have never actully used it. That would be the way to go.
CornedBee
Sep 3rd, 2004, 04:07 AM
The XHTML attribute disabled should be set to "disabled" to disable and to "" (or removed) to enable.
The JavaScript property disabled should be set to true or false.
If you use setAttribute in JavaScript, use the values for the attribute.
Acidic
Sep 3rd, 2004, 04:10 AM
Originally posted by CornedBee
The XHTML attribute disabled should be set to "disabled" to disable and to "" (or removed) to enable.
If you leave it blank, then it's not valid. Otherwise thanks a lot for that.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.