This S.O. gives some quick examples: https://stackoverflow.com/questions/5416767/get-selected-value-text-from-select-on-change
May 8, 2020
5
Level 1
how to display current selected option when using onchange() function on select tag
hello, in my dropdown menu, i linked the option tag to a url , it goes to the url, but the the dropdown list is showing "select channel" instead of the option selected
here's the code :
<select class="form-control" id="channel_list" name="channel_list" onchange="location = this.value;">
<option value="">Select Channel</option>
@foreach(App\Channel::all() as $channel)
<option value="/threads/{{ $channel->slug }}" >
{{ $channel->name }}
</option>
@endforeach
</select>
Level 122
of course if goes back to select channel. You have done nothing to tell it which entry it should be on.
perhaps something lke
<select class="form-control" id="channel_list" name="channel_list" onchange="location = this.value;">
<option value="">Select Channel</option>
@foreach(App\Channel::all() as $channel)
<option value="/threads/{{ $channel->slug }}"
@if (request()->is('threads/' . $channel->slug)) selected @endif
>
{{ $channel->name }}
</option>
@endforeach
</select>
1 like
Please or to participate in this conversation.