Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8518469
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:59:09+00:00 2026-06-11T05:59:09+00:00

I have a table where it makes a whole row clickable when a link

  • 0

I have a table where it makes a whole row clickable when a link is added to any cell. What I would like to do is add this script to multiple tables on a page. The problem is the script will only work with one table since it can only be used with id and not class css. How do I add multiple table ids?

      window.onload = function(){
      ConvertRowsToLinks("results-table"); //My table id
      // ConvertRowToLinks("results-table", "results-table2");
      // I would like to add results-table2, results-table3 etc...

  }

  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=''");
      }
    }


    ConvertSideRowsToLinks("sidebar-table");
  }

  function ConvertSideRowsToLinks(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=''");
      }
    }

  }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T05:59:10+00:00Added an answer on June 11, 2026 at 5:59 am

    You can also slice arguments this way you can pass as many ids as you want, and you don’t have to create array explicite:

      function ConvertSideRowsToLinks()
      {
        var ids = Array.prototype.slice.call(arguments)
        for (var key in ids)
        {
            var table =  document.getElementById(ids[key])
            var rows =table.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=''");
            }
          }
        }
      }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a idea to make table like this 1. something1 2. something2 3.
I would like to know which row has fired a trigger on a table.
I have a table, containing a checkbox to select the whole row (or not).
I saw this link (http://stackoverflow.com/questions/6603868/android-onclicklistener-and-table-layout) which seems like it works for the person asking
I have a table (customer) with 10,000 records. I would like to modify every
I have a simple table <table border=1> <tr> <td>row 1, cell 1</td> <td>row 1,
Given a table like this, where x and y have a unique constraint. id,x,y
I have a table with a lot of rows, which makes the page scroll.
I have a custom table that has a custom format to it, which makes
I have a homepage.html and it refers to styles.css(makes a table). But I also

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.