/    Sign up×
Community /Pin to ProfileBookmark

Make text appear in color in textarea

<html>
<head>
<script language=”javascript”>
function call() {
var result, fMath, fEng;
fMath = parseInt(math.value);
fEng = parseInt(eng.value);
result = fMath+fEng;
nResult.value = “<FONT COLOR=”RED”>” +result +”</FONT>”;
}
</script>
</head>
<body>
MATHEMATICS :<INPUT type=”text” NAME=”math”><br>
ENGLISH :<INPUT type=”text” NAME=”eng”><br>
RESULT :<TEXTAREA NAME=”nResult” COLS=”50″ ROWS=”50″ READONLY></TEXTAREA><br>
<input type=”button” name=”add” value=”RESULT” onClick=”call()”>
</body>
</html>

Thanks. On line 9th of this code snippet which is – nResult.value = “<FONT COLOR=”RED”>” +result +”</FONT>”; i want the result variable to appear in red in the textarea. This only restrieves it as string.
Please help, how do i do it?

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@FangFeb 13.2010 — document.[I]formName[/I].nResult.value = result;
document.[I]formName[/I].nResult.style.color = 'red';
×

Success!

Help @ken2010 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 6.17,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...