Entry
How can I restore bgcolor in rows when checkbox is uncheked?
Dec 17th, 2001 08:49
Yamuna Pattathil, Roy Haaland, Martin Honnen
This is just a slight variation from
http://www.faqts.com/knowledge_base/view.phtml/aid/1574/fid/192
<html>
<head>
<script>
function highlightRow (element, color1, color2) {
var chk = element.checked;
while (element.tagName.toUpperCase() != 'TR' && element != null)
element = document.all ? element.parentElement : element.parentNode;
if (element && chk) {
element.bgColor = color1;
} else {
element.bgColor = color2;
}
}
</script>
</head>
<body>
<form name="form1">
<table border="1">
<tr bgcolor="red">
<td><input type="checkbox" name="check" onclick = "highlightRow
(this, 'yellow', 'red');"></td>
<td> data1 </td><td> data2 </td><td> data3 </td>
</tr>
<tr bgcolor="red">
<td><input type="checkbox" name="check" onclick = "highlightRow
(this, 'yellow', 'red');"></td>
<td> data4 </td><td> data5 </td><td> data6 </td>
</tr>
</table>
</form>
</body>
</html>