Forum Moderators: not2easy
...connection strings and sql, blah blah
<Table class="dblist">
<TR class="dbrow">
<TD>Manufacturers</TD>
</TR>
<%
While Not objRS.EOF
intLineNum = intLineNum + 1
If intLineNum Mod 2 = 0 Then
strLineColor = strEvenColor
Else
strLineColor = strOddColor
End If
%>
<TR <%=strLineColor%>>
<TD class="dbdata"><a href="<%= (objRS("WebAddress")) %>"><%= objRS("Name") %></a></TD>
</TR>
<%
strLineColor alternates the row colors. All works well.
What i'd like to do is add an a:hover to the css code, so when the mouse passes over the colored rows it will appear as a highlight or third color. Here is the css.
# #dblist {
* border : 1px;
* border-color : #000000;
* border-collapse : collapse;
}
# tr.dbrow {
* border : 1px;
* background-color : #ff7200;
* font-family : Verdana, Tahoma, Sans;
* font-size : small;
* font-weight : bolder;
* text-align : center;
* text-decoration : none;
}
# td.dbdata {
* font-family : Verdana, Tahoma, Sans;
* font-size : smaller;
* font-weight : bolder;
* text-align : left;
}
Thank you all in advance for your help.
[littlecandyshop.com...]
(first off, personal URLs aren't allowed here)
To answer your question, IE won't hover over anything that's not an <a> element so we have to use some javascript. Assuming you give your <table> and id attribute of 'mytable', this'll fit the bill:
mytable = document.getElementById('mytable');
rows = mytable.getElementsByTagName('tr');
for (i=0; i<rows.length; i++; ) {
rows[i].onmouseover = 'this.className+=" over";';
rows[i].onmouseout = 'this.className=this.className.replace(new RegExp("\\bover\\b"), "");';
} And then in your CSS:
tr:hover, tr.over { background-color: whatever; } As a technical explanation, the Javascript loops through all the rows and adds a small function which either adds or removes a value of 'over' from the class attribute on hover (this works fine with the multiple classes you'll have from your even/odd rows). In the CSS you'll see that we've got a tr:hover which'll give the same effect for users of modern browsers who've got CSS on and Javascript off.
Hope this helps, but let me know if you're still having problems.
td.dbdata a:hover { background-color: #whatever; } Does that help?
N.b., the previous Javascript is only needed for IE. Other browsers will handle the code fine. Also, it'd help if you posted only the output code (not the ASP) and that's what we're dealing with here. I think I can see your problem though regardless.