Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

194
Views
how to get Different name for each td?

I need some help, what should I do so that all the rows have each one a different id for example:introdu1,introdu2,introdu3

var perrow = 1; 
array.forEach((value, i) => {

  myTable += `<td id="ore">${value}</td>`;
  myTable += `<td id="introdu" > </td>`;
  
  
  var next = i + 1;
  if (next%perrow==0 && next!=array.length) { myTable += "</tr><tr>"; }
});
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

It is very easy you can use ${variable} like you do in ${value}

let array = ['r','4','6'];  
let myTable = "";
var perrow = 1; 
    array.forEach((value, i) => {
    var next = i + 1;
    
      myTable += `<td id="ore${next}">${value}</td>`;
      myTable += `<td id="introdu${next}" > </td>`;
      
      if (next%perrow==0 && next!=array.length) { myTable += "</tr><tr>"; }
    });
    console.log(myTable);
td {
background : red;
}

about 4 years ago · Juan Pablo Isaza Report

0

Use a dynamically generated ID:

var perrow = 1;
var id = 1;
array.forEach((value, i) => {

  myTable += `<td id="ore${id}">${value}</td>`;
  myTable += `<td id="introdu${id++}" > </td>`;

  var next = i + 1;
  if (next % perrow == 0 && next != array.length) {
    myTable += "</tr><tr>";
  }
});
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!