5 replies [Last post]
Jenni
Jenni's picture
Offline
Enthusiast
Seattle
Last seen: 13 years 46 weeks ago
Seattle
Joined: 2007-03-09
Posts: 115
Points: 0

Is there way to "Disable" a button with CSS? I don't see that attribute (enabled: true) etc.

Thanks!

Hugo
Hugo's picture
Offline
Moderator
London
Last seen: 8 years 4 weeks ago
London
Joined: 2004-06-06
Posts: 15668
Points: 2806

No that's not a CSS role,

No that's not a CSS role, but explain in a little more detail what you are trying to achieve and someone may have an approach.

Before you make your first post it is vital that you READ THE POSTING GUIDELINES!
----------------------------------------------------------------
Please post ALL your code - both CSS & HTML - in [code] tags
Please validate and ensure you have included a full Doctype before posting.
Why validate? Read Me

Jenni
Jenni's picture
Offline
Enthusiast
Seattle
Last seen: 13 years 46 weeks ago
Seattle
Joined: 2007-03-09
Posts: 115
Points: 0

OK, well I'm making this

OK, well I'm making this AJAX button. When someone clicks on it, there is an asynchronous request sent out to the server.

I want the button to "disable", so it looks, well disabled. It becomes grayed out and inactive. You can't click it or nutin.

Sites like youtube and other ajax sites do this when a user submit or signs in to prevent double submit. I would totally think this is a css thing :?

Triumph (not verified)
Anonymous's picture
Guru

Jenni wrote:... I would

Jenni wrote:
... I would totally think this is a css thing ...

Nah, it's behavior, not styling. document.form1.button1.disabled=true;

Jenni
Jenni's picture
Offline
Enthusiast
Seattle
Last seen: 13 years 46 weeks ago
Seattle
Joined: 2007-03-09
Posts: 115
Points: 0

Shweeet. Thanks Triumph.

Shweeet. Thanks Triumph.

Triumph (not verified)
Anonymous's picture
Guru

Jenni wrote:Shweeet. Thanks

Jenni wrote:
Shweeet. Thanks Triumph.

Oh, please don't quote me on that code. It may not work at all. Smile

Edit: this one does work for me - document.forms[0].idOfButton.disabled=true;

However, it must be applied after the instance of the button to be disabled. It can be added to the onclick of the button to allow it to only be clicked once.