[Javascript] How to dim buttons

David Lovering dlovering at gazos.com
Tue Nov 11 11:04:04 CST 2003


As far as I know, any dynamic object (something which accepts a
change-of-state) can be disabled in this fashion, at least according to my
interpretation of the W3C standard.  I would generally suggest using a
white-space delimeter on both sides of the equal sign, and for anything
which is not a numeric contstant using double-quotes around the left-side
quantity.  For example:

  document.forms[0].mybutton.disabled = "true";

This will work better on a larger number of browsers of varying vintages.

IE in its later versions allows even "static" objects (like labels, TR, TD,
etc.) to be disabled in this fashion, but the results are often rather
surprising.  Instead, I would recommend changing the CSS attribute
".visible" to "hidden" for a static object, as it is more intuitive and
portable.

-- Dave Lovering

----- Original Message ----- 
From: "Robert Pollard" <rpollard at apple.com>
To: <Javascript at LaTech.edu>
Sent: Tuesday, November 11, 2003 9:37 AM
Subject: [Javascript] How to dim buttons


> Hello all,
>
> I saw a page that had JavaScript that dimmed a button with the syntax
> document.button.disabled=true.  Is this something that is available to
> all browsers or is it limited to specific ones?
>
> I've never seen this in any documentation.  Can this be done to other
> objects as well?
>
> Thanks,
>
> Robert Pollard
>
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
>
>





More information about the Javascript mailing list