View Full Version : Change color of text field on focus
jhorn17
11-22-2002, 08:39 PM
can anyone tell me a way to do this?
thanks,
Jon
Something like this?
<script>
function change(){
document.form.text.style.backgroundColor='#00FF00';
document.form.text.style.color='#FF0000' //changes font colour
document.form.area.style.backgroundColor='#DDDDDD';
}
function change2(){
document.form.area.style.backgroundColor='#00FF00';
document.form.text.style.backgroundColor='#DDDDDD';
}
</script>
<form name=form>
<Input type=text name=text onmouseup=change()>
<P><textarea name=area rows=5 cols=15 onmouseup=change2()> Hello World </textarea>
</form>
joh6nn
11-23-2002, 02:12 AM
<script>
function change(that, fgcolor, bgcolor){
that.style.color = fgcolor;
that.style.backgroundColor = bgcolor;
}
</script>
<form name=form>
<Input type=text name=text onfocus="change(this,'#FF0000','#00FF00');" onblur="change(this,'#00FF00','#FF0000');">
<P><textarea name=area rows=5 cols=15 onfocus="change(this,'#FF0000','#00FF00');" onblur="change(this,'#00FF00','#FF0000');"> Hello World </textarea>
</form>
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.