Timetable

Banda's Avatar, Join Date: Mar 2007
Light Poster
Hi everyone!
So I has tried to make timetable, but I have little problem. Here is link to my project page http://koti.mbnet.fi/veskue/lukkari/testi.php . When I choose one subject on one line, it turns to red. If I change my mind and choose new subject on same line the first selection is still red, but I want to turn it white.

Code:
<script type="text/javascript">

function changeBG( radio )
{
  var node = radio.parentNode;

  if( radio.checked == true ) {
    node.style.backgroundColor = 'red';
  }
  else {
    node.style.backgroundColor = 'white';
  }
}

</script>
</head>
<body>
<input onchange="changeBG( this );" type="radio" id="example" value="example" name="example"/><label for="example">example</label>
Here is code that i use.

Sorry for my bad english

Banda
0
pradeep's Avatar, Join Date: Apr 2005
Team Leader
You'll have to switch back the color of the radio button cells which were previously red coloured.
Here's the Javascript for the purpose, I just modified your function a bit ;-)

Code: JavaScript
function changeBG( radio )
 {
   var e = radio.form.elements;
   for(var i=0;i<e.length;i++)
   {
     if(e[i].type=='radio')
         changeBG_H(e[i]);
   }
 
 }
 
 function changeBG_H(radio)
 {
   var node =  radio.parentNode;
 
   if( radio.checked == true ) {
     node.style.backgroundColor = 'red';
   }
   else {
     node.style.backgroundColor = 'white';
   }
 }