I am trying to keep select option value selected during the edit. There I used javascript for the dynamic dependent dropdown list. But now I am facing a problem to keep option value selected during the edit. Would someone help me please to solve this problem? `edit.blade.php` -

```
<form class="form-material form-horizontal" action="{{ route('admin.commercial.orders.update', $order->id) }}" method="POST">
      @method('PUT')    
      @csrf
   <div class="row">
      <div class="col-md-6">
           <div class="form-group">
              <label class="col-md-12" for="name">Buyer Name: </label>
              <div class="col-md-12">
                 <select class="form-control select2" name="name" id="buyerName">
                     <option value="">Select Buyer</option>
                 </select>
                  @if ($errors->has('name'))
                     <small class="error">{{ $errors->first('name') }}</small>
                  @endif
              </div>
          </div>
      </div>
      <div class="col-md-6">
           <div class="form-group">
             <label class="col-md-12" for="job_name">Job Name/Title: </label>
             <div class="col-md-12">
                  <select class="form-control select2" name="job_name" id="jobName">
                      <option value="">Select Job</option>
                  </select>

                   @if ($errors->has('job_name'))
                      <small class="error">{{ $errors->first('job_name') }}</small>
                   @endif
              </div>
        </div>

      </div>
    </div>
 </form>

```

And javascript for dependant dropdown-

```
<script type="text/javascript">

   $(function () {
      $(".select2").select2();
   });

   /** Dependent Dropdowns**/
   $(function() {
       dynamicDropdown('/admin/commercial/get-buyers', '#buyerName');

       $('#buyerName').change(function() {
          let url = `/admin/commercial/get-buyer-jobs/${this.value}`;
          let target = '#jobName';
          dynamicDropdown(url, target);

        });

   });
   function dynamicDropdown(url, selector) {
      $.get(url, function (data) {
          let $select = $(selector);

          $select.find('option').not(':first').remove();

          let options = [];
          $.each(data, function(index, item) {
            options.push(`<option value="${item.id}">${item.name}</option>`);
          })

          $select.append(options);
      });
   }
</script>

```

My `edit function` is -

```
public function edit($id)
{
    $order = BuyerOrder::find($id);

    return view('admin.marchendaising.commercials.orders.edit', compact('order'));
}

```