faqts : Computers : Programming : Languages : JavaScript

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

9 of 42 people (21%) answered Yes
Recently 1 of 10 people (10%) answered Yes

Entry

how can i change the background color of an input field dynamically without a style sheet??

Apr 7th, 2008 23:29
ha mo, Colin Fraser, tushar kanti das,


All form elements except hidden support onFocus() for text entry type
fields, i.e. text and textarea. You will have to find out if that is the
right syntax, I wont be doing it myself. I am not even sure if text
boxes even have a backgound color attribute that can be reset
dynalically. If they the this is how it can be done. 
<form>
<input type="text" onFocus="if (this.form.myText.focus())
{this.form.myText.bgcolor='#ffffcc' } ">
</form>
After having written that, I seem to recall seeing text boxes witha
colored background somewhere, but this may be fanciful thinking on my
part, or maybe a database somewhere rather than web pages.
http://www.businessian.com
http://www.computerstan.com
http://www.financestan.com
http://www.healthstan.com
http://www.internetstan.com
http://www.moneyenews.com
http://www.technologystan.com
http://www.zobab.com
http://www.healthinhealth.com