Forum Moderators: open
I wrote the following piece of code:
<script>
function changeColor(cell){
cell.style.backgroundColor="lightblue";
}
</script>
<table>
<tr>
<td onClick="changeColor(this.parentNode);"><a href="inbox.jsp">Inbox</a></td>
</tr>
<tr>
<td onClick="changeColor(this.parentNode);"><a href="drafts.jsp">Drafts</a></td>
</tr>
<tr>
</table>
Please help.
regards
Rk.
<html>
<head>
<script>
function doLoad() {
tr1.style.backgroundColor='white'
tr2.style.backgroundColor='white'
var selEl=document.getElementById( 'sel' );
if ( selEl.value!= '' ) {
var el=document.getElementById( selEl.value );
if ( el ) { el.style.backgroundColor='lightblue' }
}
}
function changeColor( id ){
document.getElementById( 'sel' ).value=id;
doLoad();
}
</script>
</head>
<body onload='javascript:doLoad();' >
<form action='#' >
<input type='hidden' id='sel' value='' >
</form>
<table>
<tr id='tr1' >
<td onClick="changeColor( 'tr1' );">Inbox</td>
</tr>
<tr id='tr2'>
<td onClick="changeColor( 'tr2' );">Drafts</td>
</tr>
<tr>
</table>
</body>