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

140
Vistas
Can I add a dropdown in a form showing an existing data record with a value already in the 'edit' form using EJS?

I have a Node/Express/MySQL CRUD app that I have added dropdowns that show values from tables for the input form. I want to be able to show those dropdowns in my edit form but also show the existing selection from another data table by id. I know how to do both independently, but I am having trouble figuring out how to combine these for my edit form.

Dropdown in my input form:

<div class="col-md">
                          
  <%- include ('partials/dropdown', {
    options: marketArray.map(m => {
     return { name: m.market_name, value: m.market_id }
    }),
    name: "market",
    label: "Market"
}) -%>

</div>

I know that this is how to pass my data value by id selected into an input like:

value="<%= saleresult.market %>"

What is the correct syntax to combine this into the div containing the dropdown so the user sees the current data for the record but also has the option to edit by selecting another option from the dropdown?

I actually attempted to add a dropdown in my 'edit' form where the data record is selected by id and it throws an error saying 'marketArray is not defined'. My guess is that there is some conflict between the data by the id selected and the data from the 'market' table for the dropdown. But my inexperience at this level leaves me unable to make the connection in my mind.

Thanks in advance for the help!

about 4 years ago · Juan Pablo Isaza
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