Click to See Complete Forum and Search --> : is it possible to change the background colour of a txt box


Jaime1985
10-28-2003, 09:52 AM
I have a txt box, when the user clicks it, I want the colour to change, how is it done?
heres my code that dont work!:
<input name="Name" value="<?php echo "$fsname";?>" onMouseDown="value='', bgcolor='#ff3118'" >
bgcolor probably isnt right!

TomDenver
10-28-2003, 11:08 AM
<input type=text onFocus="this.style.backgroundColor='#AAAAFF';">


That will change the background color of the text field when it receives focus. You can use onMouseDown instead if you want. If you do this, I recommend setting an onBlur to return the background back to white when the user leaves that field. Otherwise it will just stay blue (or whatever color you set it to). To change it back to white, do this:


<input type=text
onFocus="this.style.backgroundColor='#AAAAFF';"
onBlur="this.style.backgroundColor='#FFFFFF';">


As for your PHP part in the value, I'm not familiar with PHP, so I don't know if that part is valid.