Highlight number of cells in HTML table by Javascript

I want to highlight from index 0 to input number of cell on my html table, but my code is currently just highlight the last cell of the list. is there anyway I can do something like table.rows[0:i].cells[0:j] in Javascript

$('#dOcButton').click(function() {
    $('#displayOptionalCases input').click()
    highLight()
});
function highLight(){
    numCases = parseInt(document.getElementById('input1').value)
    TableX = document.getElementById('generatedResultsTable')
        //Reset table highlight
    var rows = document.getElementsByTagName("TD");
    for(i = 0; i < rows.length; i++){
        rows[i].className= "resetCell" ;
    }
    var cell;
    var u = 1
    for(i=0; i<TableX.rows.length; i++)
    {   for(j=0; j<10; j++)     
        {
            u = u + 1
            cell=TableX.rows[i].cells[j]
            cell.className = "cellSelected"
            if (u==numCases+1){break;}
        }
        if (u==numCases+1){break;}
    }
}

152 thoughts on “Highlight number of cells in HTML table by Javascript”

  1. Hello, i think that i saw you visited my weblog thus i came
    to go back the prefer?.I am trying to to find
    things to improve my site!I guess its ok to use some of
    your ideas!!

    Reply
  2. I’m impressed, I must say. Seldom do I encounter a blog that’s both educative and amusing, and let me tell
    you, you’ve hit the nail on the head. The issue
    is something that not enough folks are speaking intelligently
    about. Now i’m very happy that I came across this in my search for something regarding this.

    Reply
  3. Hey there! Would you mind if I share your blog with my facebook group?
    There’s a lot of people that I think would really appreciate your content.

    Please let me know. Many thanks

    Reply
  4. It’s a shame you don’t have a donate button! I’d definitely donate to this fantastic blog!
    I guess for now i’ll settle for book-marking and adding your RSS
    feed to my Google account. I look forward to fresh updates and will talk about this website
    with my Facebook group. Talk soon!

    Reply
  5. An impressive share! I’ve just forwarded this onto
    a colleague who had been doing a little research on this.
    And he in fact bought me dinner because I discovered it for him…
    lol. So allow me to reword this…. Thank YOU for the meal!!
    But yeah, thanks for spending time to discuss this topic here on your
    website. cheap flights http://1704milesapart.tumblr.com/ cheap
    flights

    Reply
  6. I was curious if you ever thought of changing the page layout of your site?
    Its very well written; I love what youve got to say. But maybe you could a little more in the way of content so people could connect with it better.
    Youve got an awful lot of text for only having 1 or two pictures.
    Maybe you could space it out better?

    Reply
  7. I think everything said made a great deal of sense. But, consider this, suppose you composed a catchier post title?
    I ain’t suggesting your information isn’t solid., but what if you added a title to possibly grab a person’s attention? I mean Highlight
    number of cells in HTML table by Javascript – JavaScript Help is a little plain. You might peek at Yahoo’s front page and see how
    they create article headlines to get people to click.
    You might add a video or a pic or two to get readers
    excited about everything’ve written. In my opinion, it might bring your posts a little livelier.

    Reply
  8. i need a loan help please, i need loan for business. i need loan for education need loan now need a loan i need loan embassy finder, cash advance settlement loans, cash advances, cash advance online, 24 hr cash advance loans. Investment assets and liabilities economics, financial institution .

    Reply

Leave a Comment