/    Sign up×
Community /Pin to ProfileBookmark

is it possible to change the background colour of a txt box

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!

to post a comment
HTML

1 Comments(s)

Copy linkTweet thisAlerts:
@TomDenverOct 28.2003 — [code=php]<input type=text onFocus="this.style.backgroundColor='#AAAAFF';">
[/code]


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:

[code=php]
<input type=text
onFocus="this.style.backgroundColor='#AAAAFF';"
onBlur="this.style.backgroundColor='#FFFFFF';">
[/code]


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

Success!

Help @Jaime1985 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...