Can not seem to alter table row bgcolor using DOM

Discussion in 'Javascript' started by TC, Feb 24, 2004.

  1. TC

    TC Guest

    Hi

    I'm trying to change the background colour of a table row when a user
    puts a mouse over it or clicks on it, but for some reason the code
    does not seem to work in IE 6 even though I can alter the alignment
    attribute in IE 6. Heres a cut down version of the code I'm using

    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html;
    charset=iso-8859-1">
    <script language="JavaScript" type="text/JavaScript">
    <!--
    function changeRowBgClick(rowID)
    {

    theRow = document.getElementById(rowID);

    var vBgColor = theRow.getAttribute("bgcolor");
    //alert(vBgColor == offColor);
    if (vBgColor == "#ffffff")
    {
    alert("1 >"+theRow.getAttribute("bgcolor"));
    theRow.setAttribute("bgcolor", "#000000");
    theRow.setAttribute("align", "center");
    alert("2 >"+theRow.bgcolor);
    alert("3 >"+theRow.getAttribute("bgcolor"));

    }
    else
    {
    theRow.setAttribute("bgcolor",offColor);
    }
    alert('end of click function');

    }

    -->
    </script>



    </head>

    <body>


    <table border="1" width="100%">
    <tr>
    <td align="right" bgcolor="#ffffff" id="row<%=vID%>"
    onClick="changeRowBgClick('row<%=vID%>')">
    testing
    </td>
    </tr>
    </table>
    </body>
    </html>

    If you run this code your see that the word testing moves to the
    center but in IE the background does not change, but this code works
    fine in Mozilla.
    I hope someone can help with this as I can't see why this would occur.




    Tony Combe
    TC, Feb 24, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. simon

    BGCOLOR of the row in dataGrid

    simon, May 11, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    612
    Eliyahu Goldin
    May 11, 2004
  2. Charles Shao
    Replies:
    1
    Views:
    389
    Eliyahu Goldin
    Apr 18, 2005
  3. phl
    Replies:
    1
    Views:
    4,328
    Martin Jay
    Jun 8, 2006
  4. Martin
    Replies:
    2
    Views:
    99
    Rob B
    Nov 19, 2004
  5. -berlin.de
    Replies:
    0
    Views:
    135
    -berlin.de
    Jun 30, 2007
Loading...

Share This Page