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

147
Vistas
how can i get the value of eventname into a js query?

I have the following partial as part of my assignment to show a list of events on my website, the problem is that I want to use the value called event name in a mongo dB query so I can append the users username to the attending array based on the name of the event

<ul>
<!-- for each user-->
<% events.forEach(function(event) { %>

<form action="/attend" method="post">
    <div class="Events">
      <div class="Post" id="Post1">
        <div class="PostTitle" name = "eventname"><%= event.name %></div>
        <div class="PostDate" name = "date"> <%= event.date %></div>
        <div class="PostDescription"><%= event.description %></div>
        <div class="PostAttending" name="AttendingNum"><%= event.attendingusers.length%></div>
        <div class="PostAttendingSymbol"><span>&#128100;</span></div>
        <button class="editbutton" type="submit">Attend</button> 
      </div>
    </div>
</form>

<% }); %>

during testing i have tried this code to get the value but it is coming back as undefined

app.post('/attend', function(req, res){

 var test = {
 "event" : req.body.eventname}

 var user = req.session.currentuser

 console.log(JSON.stringify(test))
 console.log(JSON.stringify(user))
});

any help would be great as I planned on using a process like this to delete events too

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

There is no name attribute for div. If you need to uniquely identify one, use id. In your case you can also use input of hidden type with the value assigned like this:

<input type="hidden" name="eventname" value="<%= event.name %>">
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