mforan Posted November 25, 2010 Share Posted November 25, 2010 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=''"); } } } Quote Link to comment https://forums.phpfreaks.com/topic/219857-table-highlight-link/ Share on other sites More sharing options...
brianlange Posted November 29, 2010 Share Posted November 29, 2010 Can you post your html? Quote Link to comment https://forums.phpfreaks.com/topic/219857-table-highlight-link/#findComment-1140951 Share on other sites More sharing options...
mforan Posted December 5, 2010 Author Share Posted December 5, 2010 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). Quote Link to comment https://forums.phpfreaks.com/topic/219857-table-highlight-link/#findComment-1143376 Share on other sites More sharing options...
Lautarox Posted December 5, 2010 Share Posted December 5, 2010 Here's a good tutorial about this, http://imar.spaanjaars.com/312/how-do-i-make-a-full-table-row-clickable Quote Link to comment https://forums.phpfreaks.com/topic/219857-table-highlight-link/#findComment-1143410 Share on other sites More sharing options...
mforan Posted December 8, 2010 Author Share Posted December 8, 2010 works like a charm, cheers pal. Quote Link to comment https://forums.phpfreaks.com/topic/219857-table-highlight-link/#findComment-1144688 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.