Set Color (Text and Background) and Font Family of a Form-Text Box

[Total: 0    Average: 0/5]

This shows how to create a text form box that is able to alter it’s color, background color, and font family.

Body Code:

<form name=exf1>
<input type=text style="background-Color:steelblue;color:orange" name=t value="Some test text."><BR>
<input type=button value="GreenBack" onclick="setBack('green')"><BR>
<input type=button value="RedBack" onclick="setBack('red')"><BR>
<input type=button value="BlueFont" onclick="setFont('blue')"><BR>
<input type=button value="YellowFont" onclick="setFont('yellow')"><BR>
<input type=button value="Verdana" onclick="setF('Verdana')"><BR>
<input type=button value="Symbol" onclick="setF('Symbol')"><BR>
</form>

<script>
var isIE = document.all?true:false;
var isNS = document.layers?true:false;
function setBack(_c) {
  if (isIE) document.exf1.t.style.backgroundColor=_c;
}
function setFont(_c) {
  if (isIE) document.exf1.t.style.color=_c;
}
function setF(_c) {
  if (isIE) document.exf1.t.style.fontFamily=_c;
}
</script>

Times Viewed: 0

Leave a Reply

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