Combobox brings only one result of the Mysql table (NodeJS + JavaScript)

0

I am able to bring in only a value in the combobox that is in the table of mysql, I need to be listed both items in the same combobox. It is appearing one in a combobox and the other just below.

<div class="container">
    <% if(busca.length > 0) { %>
        <% for(var i = 0; i < busca.length; i++) {%> 
            <select>
                <option value="0"selected="selected"><%=busca[i].category_name%></option>
            </select>
</div>

    
asked by anonymous 29.04.2018 / 19:32

1 answer

1

Just put the select tags outside the loop:

<% if(busca.length > 0) { %>
    <select>
    <% for(var i = 0; i < busca.length; i++) {%> 
            <option value="0"selected="selected"><%=busca[i].category_name%></option>
    <% } %>
    </select>
    
29.04.2018 / 19:40