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

138
Views
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
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!