Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Highlight Table Row on Mouseover

Status
Not open for further replies.

Byn

Technical User
Sep 3, 2001
25
AU

Hi,

Could someone please tell me how I can highlight a complete table row on mouseover. The table has been imported from Excel and consists of approx. 150 rows and 5 columns.


Thanks,

Byn


 
try this code, put this between the head tag:

Code:
<script language=&quot;JavaScript1.2&quot;>
function changeto(highlightcolor){
source=event.srcElement
if (source.tagName==&quot;TR&quot;||source.tagName==&quot;TABLE&quot;)
return
while(source.tagName!=&quot;TR&quot;)
source=source.parentElement
if (source.style.backgroundColor!=highlightcolor&&source.id!=&quot;ignore&quot;)
source.style.backgroundColor=highlightcolor
}
function changeback(originalcolor){
if (event.fromElement.contains(event.toElement)||source.contains(event.toElement)||source.id==&quot;ignore&quot;)
return
if (event.toElement!=source)
source.style.backgroundColor=originalcolor
}
</script>

Note:
If you want to exempt a specific row for a highlight put in the <tr id=&quot;ignore&quot;>


then on your each of your <tr> tag put this:

Code:
onMouseover=&quot;changeto('#eff7ff')&quot; onMouseout=&quot;changeback('#FFFFcc')&quot;


or if u want more clarifications try this link:



I hope this helps!


bignewbie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top