Forms Colors By Class

[Total: 0    Average: 0/5]

This example shows how to change the background and font color of a textbox.

Head Code:

<style>
.t0 { color: brown; background-color: pink; }
.t1 { color: darkblue; background-color: gold; }
</style>

Body Code:

<form name=f1>
<textarea class=t1 id=textone>stuff in the box
</textarea>
<BR><input type=button value="Change" onclick="doIt()">
</form>
<script>
var _I=1;
function doIt()
{
  _I=(_I+1)%2;
  /* example is for DOM browsers only */
  if(document.getElementById)
    document.getElementById("textone").className="t"+_I;  
}
</script>

Times Viewed: 4

Leave a Reply

Your email address will not be published. Required fields are marked *