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

241
Views
How can I add element from my express server to my html table?

I want to add an element from server.js using express to my table in my html file. I know you can use double curly braces like "{{example}}" in the html file to import a value from the server file using res.render(views, options). But I wonder if there is a way to add a new row to a table like this :

index.html :

<table>
    <tr>
        <th>Description</th>
        <th>Adress</th>
    </tr>
    <tr>
        <td>{{description}}</td>
        <td>{{adress}}</td>
    </tr>

</table>

which add a new row everytime I call my res.render() method. Here what I have in my server file :

server.js :

app.get('/index', (req, res) => {
    var values = []
    var cursor = dbo.collection('collection').find()
    cursor.forEach(function (doc, err) {
        if (err) throw err;
        values.push(doc.name);
        values.push(doc.adress)
    }, function () {
        res.render('index', {description: values[0], adress: values[1]})
    })
})
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Express is a backend server which can set the value in the page to be pushed to front end. To add new rows to a rendered html at Front End , please use a combination of AJAX / Javascript

about 4 years ago · Juan Pablo Isaza Report

0

The ejs templating engine supports Javascript statements like the cursor.forEach in the template. Look, for example, at the <ul> example on the npm page.

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!