title: Manipulate select option from existing value on a record in database using jquery
body: <p>I have a form to edit a record from a database. So, to pull all the data from this record, I use ajax jquery and I displayed into a modal's bootsrap. The code looked like this :</p>
  
  <pre><code>&lt;div class="control-group"&gt;
  &lt;label class="control-label"&gt;Perusahaan : &lt;/label&gt;
  &lt;div class="controls"&gt;
  
      &lt;select id="perusahaan_edit" name="perusahaan-edit"&gt;
          &lt;option&gt;Tresnamuda Sejati&lt;/option&gt;
          &lt;option&gt;Jameson-Freight Semesta &lt;/option&gt;
          &lt;option&gt;Samudera Daka Line &lt;/option&gt;
          &lt;option&gt;Meridian Port Anances &lt;/option&gt;
          &lt;option&gt;StarLine&lt;/option&gt;
      &lt;/select&gt;
  
  &lt;/div&gt;
  </code></pre>
  
  <p></p>
  
  <p>See, let say on database, the value that exist is <code>StarLine</code>, how can I make it selected :</p>
  
  <p>My jquery code </p>
  
  <pre><code>$(document).on('click', '#btn-edit-dataPC', function() {
  var $this = $(this);
  var nama = $this.attr("req_id");
  
  $.ajax({
      url: "&lt;?php echo base_url() . 'administrator/control_admin/get_one_pc' ?&gt;",
      type: 'POST',
      data: {nama: nama},
      dataType: 'json',
      success: function(obj) {
          // manipulate the select option ???
  
          //Show on modal
          $('#myModal1').modal('show');
          }
      });
  });
  </code></pre>
  
  <p>Any help it so appreciated...</p>
  
  <p><strong>Update</strong></p>
  
  <p>Thanks for the reply, I got some problem here. Is it a problem if the return ajax is a json ? Coz, if I use like this :</p>
  
  <pre><code>success: function(obj) {
  
                  var value = obj.perusahaan;
  
                  $("#perusahaan_edit option").filter(function() {
                      return $(this).text() === value;
                  }).attr("selected", "selected");
  
  
                  $('#myModal1').modal('show');
              }
  </code></pre>
  
  <p>which var value is dynamic on database ?
  I got the select option is not affected.
  Thanks again ...</p>