Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

change font color

Status
Not open for further replies.

bbvic

Technical User
Oct 21, 2004
51
US
hi..
I am trying to change the font color when the checkbox is clicked.
this code works, but..
if I just want to change color of list (selection) boxes and it remains two text fields...
how can I do that??
thank you in advance..
---

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"
<html>
<head>
<title>Untitled</title>

<style type="text/css">

.readOnly { color: black; }
.readWrite { color: white; }

</style>

<script language="javascript"><!--

function SetState( bool, targ ) {
targ.readOnly = !bool;
SetColor( bool, targ );
}

function SetColor( bool, targ, flag ) {
targ.className = (bool) ? 'readOnly':'readWrite';
if (flag) SetColor( bool, targ );
<!--'readWrite' : -->
}

//--></script>
</head>

<body>

<form name="f">
<td><input type="checkbox" name="cb1" onclick="SetState(this.checked, this.form.t2, false); SetState(this.checked, this.form.t3, false);SetState(!this.checked, this.form.t1, true); SetState(!this.checked, this.form.t4, true);" /></td>
<td>

<select name="t1" class="readOnly">
<option>aa</option>
<option>ab</option>
<option>ac</option>
</select>

<!--<input type="text" name="t1" value ="a" class="readOnly" /></td>-->
<td><input type="text" name="t2" value ="b" readonly /></td>
<td><input type="text" name="t3" value ="c" readonly /></td>
<td><select name="t1" class="readOnly">
<option>a</option>
<option>b</option>
<option>c</option>
</select></td>
</form>

</body>
</html>
 
Good job bbvic, I have awarded you a star for solving your problem. Now perhaps you could post your solution so that others that are having the same problem might be able to use the search function to find this, and possibly get help from it in the future.

Additionally, I see that you are fairly new to tek-tips and you have asked some lengthy questions in the last few days. It is common courtesy when another user has helped you to click the link labeled "Thank <name> for this valuable post!!". This will award that user with a star for the post and also give them a vote for the tipmaster of the week. You can award more than one star per post, and you can even give out stars for posts that you didn't even start (much the same as the star I gave you for figuring out your problem).

-kaht

Do the chickens have large talons?
[banghead]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top