Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    May 2004
    Posts
    391
    Thanks
    76
    Thanked 0 Times in 0 Posts

    trying to highlight row color onchange

    I'm trying to highlight the row color when the input field is changed but get an error. Can someone please help. TRACY

    Code:
    <script type="text/javascript">
     function toggle(trid){
    var edited_row_bgcolor = '#FAEBD7'; 
    var elm = document.getElementById(trid); 
    document.elm.style.background = edited_row_bgcolor;
    }
    
    
     </script>
    
    
     
     <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr id="Child1">
        <td width="50%"> 
            <input onchange="toggle('Child1');" type="text" name="T1" size="20">
         </td>
        <td width="50%"></td>
      </tr>
      <tr>
        <td width="50%"><input type="text" name="T1" size="20"></td>
        <td width="50%"></td>
      </tr>
      <tr>
        <td width="50%"><input type="text" name="T1" size="20"></td>
        <td width="50%"></td>
      </tr>
      <tr>
        <td width="50%"><input type="text" name="T1" size="20"></td>
        <td width="50%"></td>
      </tr>
      <tr>
        <td width="50%"><input type="text" name="T1" size="20"></td>
        <td width="50%"></td>
      </tr>
    </table>

  • #2
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,534
    Thanks
    3
    Thanked 513 Times in 500 Posts
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    
    <head>
      <title></title>
    <script type="text/javascript">
     function toggle(trid){
    var edited_row_bgcolor = '#FF3366';
    var elm = document.getElementById(trid);
    elm.style.backgroundColor = edited_row_bgcolor;
    }
    </script>
    </head>
    
    <body>
    
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr id="Child1">
        <td width="50%">
            <input onchange="toggle('Child1');" type="text" name="T1" size="20">
         </td>
        <td width="50%">55</td>
      </tr>
      <tr>
        <td width="50%"><input type="text" name="T1" size="20"></td>
        <td width="50%"></td>
      </tr>
      <tr>
        <td width="50%"><input type="text" name="T1" size="20"></td>
        <td width="50%"></td>
      </tr>
      <tr>
        <td width="50%"><input type="text" name="T1" size="20"></td>
        <td width="50%"></td>
      </tr>
      <tr>
        <td width="50%"><input type="text" name="T1" size="20"></td>
        <td width="50%"></td>
      </tr>
    </table>
    </body>
    
    </html>
    Vic

    God Loves You and will never love you less.

    http://www.vicsjavascripts.org/Home.htm

    If my post has been useful please donate to http://www.operationsmile.org.uk/


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •