Create select box with dynamic data

Asked

Viewed 92 times

0

Good morning,

I wanted to implement in my project a select box but where the options are the "name" column of another database table, I mean, I am creating an object and it is possible to associate a previously created product through the select box that will always have the name of the products registered in the database. After selecting the desired option the application will save the product id.

Can anyone help me?

  • If you have few products use a "for" with the list of products if you are using the Laravel Slide use the "foreach" to create the html with the desired parameters, if you have many products, I advise you to do a server-side scheme, it is not very secret, use repeat throw, in either PHP Back-end or Javascript Front-end depending on how your encoding is.

1 answer

0

The simplest way would be:

<select id='TAG_OPTION' class='form-control'>
     @foreach ($tags as $tag)
           <option value="{{ $tag->ID_TAG }}">{{ $tag->NOME_TAG }}</option>
      @endforeach           
</select>
                            

Browser other questions tagged

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