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
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).

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.