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 6769087
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:09:05+00:00 2026-05-26T15:09:05+00:00

I am trying to add text to each cell in particular column via Javascript.

  • 0

I am trying to add text to each cell in particular column via Javascript. Like every 8th TD would be processed for adding text.

Tell me what I have done wrong here/why it doesn’t appear in my table:

<script type="text/javascript">
window.onload = function inventorytable() {
var tableRows = document.getElementById

("inventorytable").getElementsByTagName("tbody")[0].getElementsByTagName("tr");

for(var i = 0, l = tableRows.length; i < l; i++) {
    tds = tableRows.getElementsByTagName("td");
    var processor = tds[8].innerHTML += " Ghz"
    var ram = tds[9].innerHTML += " GB"
    var rspeed = tds[11].innerHTML += " Mhz"
}}
</script>
  • 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-05-26T15:09:06+00:00Added an answer on May 26, 2026 at 3:09 pm

    You’ve forgotten to refer to the i-th row:

    tds = tableRows[i].getElementsByTagName("td");
    

    I recommend to use:

    window.onload = function inventorytable() {
        var tableRows = document.getElementById("inventorytable").rows;
                 //or .tBodies[0].rows
    
        for(var i=0, l=tableRows.length; i < l; i++) {
            var tds = tableRows[i].cells;
            /*processor*/ tds[8].innerHTML += " Ghz"
            /*ram      */ tds[9].innerHTML += " GB"
            /*  rspeed */ tds[11].innerHTML += " Mhz"
        }
    }
    

    Do not define unused variables. If you want to clarify their use, use comments.

    Also, I have replaced .getElementsByTagName by .rows and .cells.

    Update
    JavaScript sets are zero-based. So, if you want to refer to the 4th cell, use .cells[3].
    At your previous answer, you’ve showed a fiddle. see http://jsfiddle.net/ndfh2/.

    As you can see, the first row is also getting postfixes. To not add postfixes to these cells in the first row, initiate the counter at one: for( var i=1; .. ; .. )

    Your current code does probably not work, because your rows don’t have twelve (12) rows. Remember, the number at tds[ number ] equals the index of a cell within a row, starting at zero.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to add an extra UILabel into each cell( UITableView ) I'v succeeded
I'm trying to add number from 1 to 9 from plist to each cell
I 'm trying to add text on a specific image. Its working perfectly but
I am trying to add full text search capabilities to my RoR app, but
I'm trying to add a plain text node in a zend form - the
Hey guys, I'm trying to add a textfield.text entry to an array. I want
I'm trying to add some HTML formatted text to Word using Office Interop. My
I am trying to add a link into the pop-up text bubble of a
I'm trying to add a class (.active) to a text field once the user
I am trying to add a Jquery calendar picker to a text box at

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.