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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

change a lebel color

Status
Not open for further replies.

4345487

Programmer
Dec 31, 2002
132
0
0
US
Hi,

I have the line below where the class lable is blue I also have a class label1 which is red. How can I using either class or something else change the colors in JavaScript

<tr><td <span clas=&quot;label&quot;>Company:</span></td></tr>

Thanks
 
4345487:

You can use the following javascript to change the color:

document.forms[&quot;formname&quot;].spanname.style.backgroundColor = red;


[yinyang]
Patrick
 
Hi,

I can get it to work. I like to change the Company label to red.

Thanks again.


<HTML>
<HEAD>

<SCRIPT language=&quot;javascript&quot;>

function testitem()
{
/*id = document.aForm.aText.id;
pos = id.indexOf(&quot;:&quot;);
lblname = id.substring(0,pos);
alert(lblname);*/

}

</SCRIPT>
</HEAD>
<BODY>
<FORM NAME=&quot;aForm&quot; action=&quot;chico55.asp&quot; method=&quot;post&quot;>
<table>
<tr><td><span style=&quot;color: blue;&quot;>Company:</span>
</td></tr>
<tr><td>
<INPUT TYPE=&quot;text&quot; NAME=&quot;aText&quot; id=&quot;Text1&quot; SIZE=&quot;80&quot; VALUE=&quot;Scriptology&quot;>
</td></tr>

</table>
<INPUT TYPE=&quot;submit&quot; VALUE=&quot;test&quot; ONCLICK=&quot;testitem();&quot;>
</FORM>
</BODY>
</HTML>
 
4345487:

Here you go...sorry about that
<HTML>
<HEAD>

<SCRIPT language=&quot;javascript&quot;>

function testitem()
{

document.getElementById(&quot;company&quot;).style.color = 'red';
/*id = document.aForm.aText.id;
pos = id.indexOf(&quot;:&quot;);
lblname = id.substring(0,pos);
alert(lblname);*/

}

</SCRIPT>
</HEAD>
<BODY>
<FORM NAME=&quot;aForm&quot; id=&quot;aForm&quot; action=&quot;chico55.asp&quot; method=&quot;post&quot;>
<table>
<tr>
<td><span style=&quot;color: blue;&quot; id=&quot;company&quot; name=&quot;company&quot;>Company:</span></td>
</tr>
<tr>
<td><INPUT TYPE=&quot;text&quot; NAME=&quot;aText&quot; id=&quot;Text1&quot; SIZE=&quot;80&quot; VALUE=&quot;Scriptology&quot;></td>
</tr>
</table>
<INPUT type=&quot;button&quot; VALUE=&quot;test&quot; ONCLICK=&quot;testitem();&quot;>
</FORM>
</BODY>
</HTML>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top