Laravel – Mark value in a selection/option field as selected after comparison with an entry in array from database – Javascript

I passed an array of production locations from the controller to the edit.blade.php view. In this edit file there is a Select Option field with three entries.

In the edit.blade.php I also have a box with different products (from a products array) displayed in rows. These products can be clicked individually. After clicking on a product, I would like to compare the already entered value for production location from the product array with the already generated select option field. If they match, the field in the production locations array should be changed as selected.

All via Javascript without POST or Ajax since the data is on the page ready to be accessed.

—-
@foreach ( $data[‘produktionsort’] as $produkteOrt )
alue=”{{$produkteOrt->Ort}}” id=”{{$produkteOrt->Ort}}”> {{$produkteOrt->Ort}}
@endForeach