/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Change Text Color

how can i change text color in a text box from a dropdown with choses of red blue or black

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@samanyoluMay 26.2007 —  <br/>
&lt;script type="text/javascript"&gt;
function changeColor() {
var el = document.getElementById('myselect');
var inp = document.getElementById('smeezekitty');
inp.style.color= el.options[el.selectedIndex].value;
}
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;input type="text" value="my text" id="smeezekitty"&gt;

&lt;select id="myselect" onchange="changeColor()"&gt;
&lt;option value="blue"&gt;blue&lt;/option&gt;
&lt;option value="red"&gt;red&lt;/option&gt;
&lt;option value="green"&gt;green&lt;/option&gt;
&lt;option value="yellow"&gt;yellow&lt;/option&gt;
&lt;/select&gt;
×

Success!

Help @smeezekitty 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.16,
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,
)...