aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Change the color of a button when it is Enable/Disable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Change the color of a button when it is Enable/Disable" Watch "Change the color of a button when it is Enable/Disable" New topic
Author

Change the color of a button when it is Enable/Disable

Sam Saha
Ranch Hand

Joined: Jan 23, 2010
Posts: 104
I am using two different styleclass(commandExButton, commandExButtonDisabled). I am using a button which becomes Enable and Disable according to the conditions. Now when the button becomes Enable I want to use the "commandExButton" styleclass which will turn the letters of the button to white color. And when the button Disable I want to use the "commandExButtonDisabled" which will turn the letters of the button to grey color.

Now all the time(Enable/Disable) the letters of the button are grey because I can use the one condition. I am not sure how to use two conditions to disaplay the letters of the button white(commandExButton) when button is Enable else display Grey(commandExButtonDisabled). I am using jquery for that. I would appreciate if someone can help me on this as I am new in jquery. Thank you very much.

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61187
    
  66

I wouldn't use two "opposite" classes like this. Rather, I'd use one base class that's applied to all buttons, and another class for the disabled buttons that overrides the values in the base. That way, you never have to worry about removing any but the class for the disabled buttons.

For example, in the CSS:
The baseButton class is applied to all buttons. The disabledButton class is applied and removed as appropriate.


Of course this is all moot if all your supported browsers support CSS3 where you can do this completely with CSS.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Sam Saha
Ranch Hand

Joined: Jan 23, 2010
Posts: 104
As I am very new in jquery, I would appreciate if you could explain how to use use one class for all(including Enable) and remove that class and add another class when the button is Disable.
Sam Saha
Ranch Hand

Joined: Jan 23, 2010
Posts: 104
I am using two different styleclass(commandExButton, commandExButtonDisabled). I am using a button which becomes Enable and Disable according to the conditions. Now when the button becomes Enable I want to use the "commandExButton" styleclass which will turn the letters of the button to white color. And when the button Disable I want to use the "commandExButtonDisabled" which will turn the letters of the button to grey color.

Now all the time(Enable/Disable) the letters of the button are grey because I can use the one condition. I am not sure how to use two conditions to disaplay the letters of the button white(commandExButton) when button is Enable else display Grey(commandExButtonDisabled). I am using jquery for that. I would appreciate if someone can help me on this as I am new in jquery. Thank you very much.


Jonas Isberg
Ranch Hand

Joined: Mar 18, 2003
Posts: 118
Bear Bibeault wrote:
Did you try Bear's code? What happened?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Change the color of a button when it is Enable/Disable