faqts : Computers : Programming : Languages : JavaScript

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

41 of 62 people (66%) answered Yes
Recently 7 of 10 people (70%) answered Yes

Entry

How can I change the bgcolor of a <tr> when a checkbox has been selected, like hotmail now does?

Apr 5th, 2008 20:07
ha mo, Gareth Hay, Ravi Yalamarthy,


The following script draws a 1x4 table. Click the check boxes to 
highlight the rows.
Hope this hels.
NBear
<HTML>
<HEAD><TITLE>basic</TITLE></HEAD>
<BODY>
<TABLE>
<FORM>
<TR id="row1"><TD><INPUT id='cb1' type="checkbox" 
onclick="document.forms[0].cb1.checked ? 
row1.style.background='ff0000' : 
row1.style.background='ffffff'">Test</TD></TR>
<TR id="row2"><TD><INPUT id='cb2' type="checkbox" 
onclick="document.forms[0].cb2.checked ? 
row2.style.background='00ff00' : 
row2.style.background='ffffff'">Test</TD></TR>
<TR id="row3"><TD><INPUT id='cb3' type="checkbox" 
onclick="document.forms[0].cb3.checked ? 
row3.style.background='0000ff' : 
row3.style.background='ffffff'">Test</TD></TR>
<TR id="row4"><TD><INPUT id='cb4' type="checkbox" 
onclick="document.forms[0].cb4.checked ? 
row4.style.background='ff00ff' : 
row4.style.background='ffffff'">Test</TD></TR>
</TABLE>
</FORM>
</BODY>
</HTML>
http://www.businessian.com
http://www.computerstan.com
http://www.financestan.com
http://www.healthstan.com
http://www.internetstan.com
http://www.moneyenews.com
http://www.technologystan.com
http://www.zobab.com
http://www.healthinhealth.com