Combobox brings only one Mysql table result (Nodejs + Javascript)

Asked

Viewed 125 times

0

I am able to bring in the combobox only one value that is in the mysql table, I need to list the two 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>

inserir a descrição da imagem aqui

1 answer

1

Just put the select tags out of 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>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.