Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

147
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda