Welcome to WebmasterWorld Guest from 54.166.150.205

Forum Moderators: open

Message Too Old, No Replies

Checkbox changes css class

checkbox changes css class

     
4:44 pm on Feb 3, 2005 (gmt 0)

New User

10+ Year Member

joined:Feb 3, 2005
posts:2
votes: 0


I would like a checkbox to be able to change a table / div tags css class. Does anyone have code to do this, or a tutorial I could look at? Thanks
7:11 pm on Feb 3, 2005 (gmt 0)

New User

10+ Year Member

joined:Feb 3, 2005
posts:2
votes: 0


got it, maybe this will be helpful for someone


<html>
<head>
<title>Untitled</title>
<script type="text/javascript">
<!--
function toggle(box,theId) {
if(document.getElementById) {
var cell = document.getElementById(theId);
if(box.checked) {
cell.className = "on";
}
else {
cell.className = "off";
}
}
}
// -->
</script>
<style type="text/css">
<!--
.off {
background-color: #fff;
}
.on {
background-color: #ccc;
}
-->
</style>
</head>
<body>
<table border="1" cellpadding="5" cellspacing="0">
<tr><td class="off" id="cell1">
<input type="checkbox" onclick="toggle(this,'cell1')">Yada Yada Yada
</td></tr>
<tr><td class="off" id="cell2">
<input type="checkbox" onclick="toggle(this,'cell2')">Yada Yada Yada
</td></tr>
</table>
</body>
</html>
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members