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

155
Views
¿Cómo agregar una variable de lista en una cadena html?

Actualmente estoy usando una cadena html para crear un pdf. En esa cadena html necesito pasar una variable de lista. El problema es que necesito crear una tabla usando esa variable de lista. Pero cuando trato de asignarlo a una variable dentro del parámetro del script en la cadena html, no se asigna.

 let amountList= [ { name: 'store Amount', amount: 0 }, { name: 'reinventAmount', amount: 0 }, { name: 'Cost Amount', amount: 90 }, { name: 'Total Amount', amount: 90 } ]; let htmlStringUsedforPdf= `<html> <body> <table> <thead> </thead> <tbody class="sub-text" id="testBody"></tbody> </table> <script> function loadTableData(items) { const table = document.getElementById("testBody"); items.forEach( item => { let row = table.insertRow(); let name= row.insertCell(0); name.innerHTML = item.name; let amount= row.insertCell(1); amount.innerHTML = item.amount; }); } loadTableData(${amountList}); </script> <body> </html>` The table is created without the amountList data.
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Pude resolver el problema encadenando la lista. Parece que no se asignó porque html era una cadena. La solución fue

 amountList = JSON.stringify(amountList)
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!