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!