Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change Button Color

Status
Not open for further replies.

duckytn

Programmer
Dec 8, 2002
5
US
I am trying to change the color of a submit button when the value of a text box is changed. Can't seem to figure this one out. Any help would be appreciated.
 
You can do what you want by changing the "style" property of you button. For exemple, if you button id attribute value is "SubBtn", This example will change it's background color to red when clicked :
Code:
<Script>
function test() {
  var oBtn=document.getElementById(&quot;SubBtn&quot;);
  oBtn.style.background = &quot;#FF0000&quot;;
}
</Script>

...

<input type=&quot;submit&quot; id=&quot;SubBtn&quot; value=&quot;test&quot; onclick=&quot;test();&quot;/>
Water is not bad as long as it stays out human body ;-)
 
Worked like a charm !!! Thanks a bunch !
Cheers!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top