Forum Moderators: open
<body><table><tr>
<td id="one" style="background:#fff">
Si<input type="radio" name="occupwk1" value="1"
onclick="document.getElementById('one').style.background='red'" />
No<input type="radio" name="occupwk1" value="0"
onclick="document.getElementById('one').style.background='green'" />
</td></tr></table></body></html>
This does what I want it to, however I have up to 16 boxes like that in the table, and I was wondering if there was any way to do this without having to specify nn ID for each box(td).
Is there a way with JS where I can simply adjust a property of the parent element?
I got this example working in Opera and IE. I tried to make it into a simpler function() with no success :(
<html>
<body>
<table>
<tr>
<td style="background:#fff">
Si<input type="radio" name="occupwk1" value="1"
onclick="this.parentNode.style.background='red'" />
No<input type="radio" name="occupwk1" value="0"
onclick="this.parentNode.style.background='green'" />
</td>
</tr>
</table>
</body>
</html>