title: set selectbox as selected while updating opened in modal
body: <p>Here am I updating the data through modal and its working but the thing is, I want to show the selected data as selected. The update function is working but not getting idea for the value to be selected.</p>
  
  <p><strong>Here is my view</strong></p>
  
  <pre><code>&lt;td&gt;&lt;a class="btn btn-primary vehicle_user" data-toggle="modal" data-target="#myModaledit" id="&lt;?php echo $row-&gt;id;?&gt;"  vehicle="&lt;?php echo $row-&gt;vehicle_id; ?&gt;"&gt;Edit&lt;/a&gt;&lt;/td&gt;
  </code></pre>
  
  <p><strong>This is my modal</strong></p>
  
  <pre><code>&lt;div class="modal fade" id="myModaledit" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"&gt;
    &lt;div class="modal-dialog" role="document"&gt;
      &lt;div class="modal-content"&gt;
        &lt;div class="modal-header"&gt;
          &lt;button type="button" class="close" data-dismiss="modal" aria-label="Close"&gt;&lt;span aria-hidden="true"&gt;&amp;times;&lt;/span&gt;&lt;/button&gt;
          &lt;h4 class="modal-title" id="myModalLabel"&gt;Edit Vehicle&lt;/h4&gt;
        &lt;/div&gt;
        &lt;form action="&lt;?php echo base_url();?&gt;vehicle/vehicle_control/edit_vehicle_user" method="post"&gt;
          &lt;div class="modal-body"&gt;
  
  
            &lt;div class="form-group"&gt;
              &lt;label for="vehicle" class="control-label"&gt;Vehicle:&lt;/label&gt;
              &lt;select name="vehicle" class="form-control"&gt;
                &lt;?php foreach($vehicles as $res){?&gt;
                  &lt;option  &lt;?php if($res-&gt;id==$row-&gt;vehicle_id)echo 'selected' ?&gt;  value="&lt;?php echo $res-&gt;id;?&gt;"&gt;&lt;?php echo $res-&gt;name;?&gt;&lt;/option&gt;
                &lt;?php }?&gt;
              &lt;/select&gt;
            &lt;/div&gt;
        &lt;/div&gt;
          &lt;div class="modal-footer"&gt;
            &lt;input type="hidden" name="id" value="" id="vehicle_user_id"&gt;
            &lt;button type="button" class="btn btn-default" data-dismiss="modal"&gt;Close&lt;/button&gt;
            &lt;button type="submit" class="btn btn-primary"&gt;Save changes&lt;/button&gt;
          &lt;/div&gt;
        &lt;/form&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Here is my jQuery script</p>
  
  <pre><code>$(document).ready(function() {
      $(".vehicle_user").click(function() {
          var id = $(this).attr('id');
          //alert(id);
  
          $("#vehicle_user_id").val(id);
          $("#vehicle").val($(this).attr('vehicle'));
      });
  });
  </code></pre>