Go4Expert

Go4Expert (http://www.go4expert.com/)
-   JavaScript and AJAX (http://www.go4expert.com/forums/javascript/)
-   -   Timetable (http://www.go4expert.com/forums/timetable-t3377/)

Banda 13Mar2007 11:05

Timetable
 
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

pradeep 13Mar2007 17:10

Re: Timetable
 
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';
   }
 }



All times are GMT +5.5. The time now is 15:10.