Home > front end >  Generating a large dropdown list
Generating a large dropdown list

Time:04-21

I'm making a large form in Laravel 8 and one of the dropdown lists has to contain values from 1 to 85.

Is there a way that I can generate the list using a loop instead of having to type out the whole 85 options?

My current code is

    <div >
       <div >
          <select  name="map1_id" data-style="select-with-transition" title="" data-size="40">
             @foreach($user as $users)
                <option value="{{$users->map1}}" @if (old('map_id', $users->map1)) selected="selected" @endif>{{$users->map1}}</option>
             @endforeach
         </select>
       @include('alerts.feedback', ['field' => 'map1id'])
   </div>
</div>

CodePudding user response:

@for ($i = 1; $i < 86; $i  )

@endfor

https://laravel.com/docs/9.x/blade#loops

  • Related