Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Return button Style to Default

Reply
Thread Tools

Return button Style to Default

 
 
Rick Brandt
Guest
Posts: n/a
 
      03-06-2006
I am using some buttons to hide/show various divs and am changing the style of
the button to indicate which button's view is "active".

My problem is that for the non-active buttons I want the default look. Once I
change a button's style to something else what is the style setting to revert
them back to this default?

EX:
Button starts at default.

Upon press set different background
document.getElementById("btnName").style.backgroun d = "someColor"

What command changes it back? I've tried "" and that seems to work (you guessed
it) in FF, but not in IE. I also tried ThreeDFace with the same effect (good in
FF, bad in IE).

TIA



 
Reply With Quote
 
 
 
 
RobG
Guest
Posts: n/a
 
      03-06-2006
Rick Brandt wrote:
> I am using some buttons to hide/show various divs and am changing the style of
> the button to indicate which button's view is "active".
>
> My problem is that for the non-active buttons I want the default look. Once I
> change a button's style to something else what is the style setting to revert
> them back to this default?
>
> EX:
> Button starts at default.
>
> Upon press set different background
> document.getElementById("btnName").style.backgroun d = "someColor"


Changing the style object's *backgroundColor* property between 'red' and
'' seems to work fine for me in IE 6.

<button id="btn"
onclick="alert(this.style.backgroundColor);">butto n</button>
<button
onclick="document.getElementById('btn').style.back groundColor = 'red';"
>Make it red</button>

<button
onclick="document.getElementById('btn').style.back groundColor = '';"
>Revert to default</button>





This is more a CSS question, it may be better answered in
news:comp.infosystems.www.authoring.stylesheets



--
Rob
 
Reply With Quote
 
 
 
 
Rick Brandt
Guest
Posts: n/a
 
      03-06-2006
"RobG" <(E-Mail Removed)> wrote in message
news:_YMOf.614$(E-Mail Removed)...
> Rick Brandt wrote:
>> I am using some buttons to hide/show various divs and am changing the style
>> of the button to indicate which button's view is "active".
>>
>> My problem is that for the non-active buttons I want the default look. Once
>> I change a button's style to something else what is the style setting to
>> revert them back to this default?
>>
>> EX:
>> Button starts at default.
>>
>> Upon press set different background
>> document.getElementById("btnName").style.backgroun d = "someColor"

>
> Changing the style object's *backgroundColor* property between 'red' and ''
> seems to work fine for me in IE 6.
>
> <button id="btn"
> onclick="alert(this.style.backgroundColor);">butto n</button>
> <button
> onclick="document.getElementById('btn').style.back groundColor = 'red';"
> >Make it red</button>

> <button
> onclick="document.getElementById('btn').style.back groundColor = '';"
> >Revert to default</button>


Thanks, I'll check recheck, but I could have sworn that when I first tried
backgroundColor I got errors. Maybe I had the case wrong? Does the case have
to be just as you have it?

> This is more a CSS question, it may be better answered in
> news:comp.infosystems.www.authoring.stylesheets


Yeah, but since it was about setting the style in js I figured they would just
send me here : )

Thanks again.



 
Reply With Quote
 
RobG
Guest
Posts: n/a
 
      03-06-2006
Rick Brandt wrote:
> "RobG" <(E-Mail Removed)> wrote in message
> news:_YMOf.614$(E-Mail Removed)...

[...]
>
> Thanks, I'll check recheck, but I could have sworn that when I first tried
> backgroundColor I got errors. Maybe I had the case wrong? Does the case have
> to be just as you have it?


Yes. HTML isn't case sensitive (in general) but JavaScript is.


>>This is more a CSS question, it may be better answered in
>>news:comp.infosystems.www.authoring.stylesheets

>
>
> Yeah, but since it was about setting the style in js I figured they would just
> send me here : )


Your issue actually is with JavaScript, but there you may have received
more (authoritative) information about using styles with buttons (or
not...).


--
Rob
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to set a button from a user control the default button on an aspx page AlecL ASP .Net 2 02-12-2007 09:15 PM
what value does lack of return or empty "return;" return Greenhorn C Programming 15 03-06-2005 08:19 PM
error C2440: 'return' : cannot convert from 'const char *' to 'const unsigned short *' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast Abhijit Bhadra C++ 2 12-01-2004 04:43 PM
Need help with Style conversion from Style object to Style key/value collection. Ken Varn ASP .Net Building Controls 0 04-26-2004 07:06 PM
default submit button in multi-button form Andrew Crowe HTML 2 02-06-2004 10:44 PM



Advertisments