Timetable

Discussion in 'JavaScript and AJAX' started by Banda, Mar 13, 2007.

  1. Banda

    Banda New Member

    Joined:
    Mar 12, 2007
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    0
    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
     
  2. pradeep

    pradeep Team Leader

    Joined:
    Apr 4, 2005
    Messages:
    1,645
    Likes Received:
    87
    Trophy Points:
    0
    Occupation:
    Programmer
    Location:
    Kolkata, India
    Home Page:
    http://blog.pradeep.net.in
    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:
     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';
       }
     }
     
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice