Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

239
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda