/    Sign up×
Community /Pin to ProfileBookmark

change color of a value in a form element

<body>
<form action=”http://tl28serv.uws.edu.au/iwsdinfo/form.asp” method=”post” name=”test” >
income
<input type=”text” name=”in” size=”20″ value=”0.00″ />
&nbsp;
expenses
<input type=”text” name=”exp” size=”30″ value=”0.00″ onblur=”abc(this)”/>
<br />

<input type=”text” name=”bal” size=”30″ disabled value=”0.00″ />

<br />
<input type=”button” value=”submit” />&nbsp; <input type=”reset” />

</form>
<p><a href=”http://validator.w3.org/check/referer“>
<img src=”http://www.w3.org/Icons/valid-xhtml10
alt=”Valid XHTML 1.0!” height=”31″ width=”88″ />
</a>
</p>
</body>
</html>

i want to change the color of value i get for input box bal when (in-exp).
if the value is – then the bal color becomes red otherwise blue.

igot the values for bal using diffrent amounts but i couldnt change the color.

pl help

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@violent_jApr 28.2004 — <input type="text" name="exp" size="30" value="0.00" onblur="abc(this)" onchange="setcolor()"/>

function setcolor() {

if (document.test.exp.value=='-') {

document.test.bal.color='#FF0000';

} else {

document.test.bal.color='#0000FF';

}

}

grtz
×

Success!

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