3 replies [Last post]
samf
samf's picture
Offline
Enthusiast
Los Angeles, CA
Last seen: 7 years 41 weeks ago
Los Angeles, CA
Timezone: GMT-5
Joined: 2003-09-29
Posts: 106
Points: 34

Those with IE, right-click in your browser. Notice the context menu has some options that are grey'ed out to mean "disabled" -- I know I can do that with form elements and checkboxes and the like, but can that be done with text?

Ever so grateful,

Sam Fullman

Life is complex -- don't make it complicated. If you need help with PHP visit PHP Builder

samf
samf's picture
Offline
Enthusiast
Los Angeles, CA
Last seen: 7 years 41 weeks ago
Los Angeles, CA
Timezone: GMT-5
Joined: 2003-09-29
Posts: 106
Points: 34

D'oh!!

Like that was hard! You can do it one of two ways:

1. <div id="disme" disabled ... >This text is disabled</div>

2. <div id="disme" ... >This text is also disabled</div>
<script>disme.disabled=true;</script>

Hope that helps someone
Sam

Life is complex -- don't make it complicated. If you need help with PHP visit PHP Builder

dJomp
dJomp's picture
Offline
Enthusiast
Last seen: 4 years 4 weeks ago
Joined: 2003-03-23
Posts: 422
Points: 0

making text appear disabled

If we look at the W3's HTML spec for disabled (http://www.w3.org/TR/html401/interact/forms.html#adef-disabled), it says

Quote:
The following elements support the disabled attribute: BUTTON, INPUT, OPTGROUP, OPTION, SELECT, and TEXTAREA.
So just a warning that it's probably only IE that supports what you've done there!

Also IE just seems to have changed the text colour to gray. Why not just make a class ".disabled" and set what you want disabled text to look like?

You know you're a geek when you try to shoo a fly away from the monitor with your cursor.

samf
samf's picture
Offline
Enthusiast
Los Angeles, CA
Last seen: 7 years 41 weeks ago
Los Angeles, CA
Timezone: GMT-5
Joined: 2003-09-29
Posts: 106
Points: 34

one good reason

There was actually another cool reason to use "disabled" as a single attribute (like nowrap) inside a div, because it does two things:

<script language="Javascript">
if(document.all.thatDiv.disabled==true){
   //you can treat clicks on that particular element differently
}
<

Now I don't know if you can do some tag like "studly" and then say:

if(document.all.thatDiv.studly==true{
//hi you big hunk of div tag..
}

cause I haven't tried it but it's nice to have a tag accomplish two things.

Elegance is always better than legality Smile

Sam[/code]

Life is complex -- don't make it complicated. If you need help with PHP visit PHP Builder