Jump to content

Table highlight link


mforan

Recommended Posts

Ive got this code that makes it so when a user hovers over a table row they can click anywhere i nthat row and it goes to the link... at the moment it will only grab one <a> and if there are 2 in the row, the hovering and color change does not work. i tryed setting "rows.getElementsById("test")", assuming that it would grab the <a href> value because it contains a id="test" value. This does not work thou!

 

Has anyone got any idea how to get this to work?

 

function ConvertRowsToLinks(xTableId){
var rows = document.getElementById(xTableId).getElementsByTagName("tr");
for(i=0;i<rows.length;i++){
var link = rows[i].getElementsByTagName("a")
	if(link.length == 1){
	rows[i].onclick = new Function("document.location.href='" + link[0].href + "'");
	rows[i].onmouseover = new Function("this.className='highlight'");
	rows[i].onmouseout = new Function("this.className=''");
	}
}
}

Link to comment
https://forums.phpfreaks.com/topic/219857-table-highlight-link/
Share on other sites

i dont believe the html code is required to answer this, is it? All i want it to do is:

 

on mouse over row, change color and make row clickable as a link using link ID X

 

 

The first post contains script to make the row change color on mouse over and make it clickable. But it only works if there is one link in the row.

 

i want to make it so there can be multiple links, yet still be a color change in the row for the clickable link(s).

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.