Forum Moderators: open

Message Too Old, No Replies

how to make a button with disable and invisible?

how to make a button with disable and invisible?

         

xbl01234

9:32 am on Dec 21, 2006 (gmt 0)

10+ Year Member



Hello;
how to make a button with disable and invisible? or let the button has light blue color? Thanks

<input type="button" value="Hello world!">

penders

12:44 pm on Dec 21, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You can make the button disabled, by using the disabled attribute of the <input> tag, but to make the button invisible you need to use CSS (presumably you want to make it visible later?)

<input style="visibility:hidden;" type="button" value="Hello world!" disabled>

If, however, you simply want to make the form control hidden - you don't want the end user to ever have control over the element, then consider using

type="hidden"
. Although this is not a button!?

To style the button in other ways, you need to use CSS. (Perhaps/preferebly with an external stylesheet.) Using an inline style in this case...

<input style="background-color:#ccf;" type="button" value="Hello world!">

Will give the button a light blue (#ccf) background.

xbl01234

9:08 pm on Dec 21, 2006 (gmt 0)

10+ Year Member



Thanks a lot

rocknbil

10:34 pm on Dec 21, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It might be helpful to note that buttons in themselves are worthless without Javascript or some other client side programming. Inherently they don't do anything. That being said, if Javascript (or other client-side programming) is disabled, they still . . . won't do anything. :-)

So if your intent is to disable the button to avoid double-clicks, use a submit button instead. This will still allow Javascript-disabled browsers to use your button:

<form>
<input type="submit" onClick="this.disabled=true;" value="Submit">
</form>

xbl01234

11:19 pm on Dec 21, 2006 (gmt 0)

10+ Year Member



Thanks for your suggestion.

This is another choice for me.