Answer the question
In order to leave comments, you need to log in
How to make active the current value of an option for a select?
It is necessary to make an active option on onload in accordance with the title
I pull the data from the database and in the blade I make the output as follows:
@foreach ($suggestions as $value)
<option value="{{ $value->id }}">{{ $value->title }}</option>
@endforeach
Answer the question
In order to leave comments, you need to log in
<option
value="{{ $value->id }}"
@if($value->id === $youId)
selected
@endif
>
{{ $value->title }}
</option>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question