title: How to make value in autocomplete jquery ui?
body: <p>In my <code>user</code> table I have <code>id_user</code> and <code>name</code>. My autocomplete searches only by name. I need <code>id_user</code> to input into the database. Usually, we can write <code>id_user</code> as a value attribute in the input tag. This is the code :</p>
  
  <p>Controller :</p>
  
  <pre><code>function get_autocomplete(){
          if (isset($_GET['term'])) {
              $result = $this-&gt;User_model-&gt;search($_GET['term']);
              if (count($result) &gt; 0) {
              foreach ($result as $row)
                  $arr_result[] = $row-&gt;name;
                  echo json_encode($arr_result);
              }
          }
      }
  </code></pre>
  
  <p>Model :</p>
  
  <pre><code>function search($name){
          $this-&gt;db-&gt;like('name', $name , 'both');
          $this-&gt;db-&gt;order_by('name', 'ASC');
          $this-&gt;db-&gt;limit(10);
          return $this-&gt;db-&gt;get('user')-&gt;result();
      }
  </code></pre>
  
  <p>View :</p>
  
  <pre><code>&lt;input type="text" id="name" placeholder="Name" name="id_user"&gt;
  &lt;script type="text/javascript"&gt;
          $(document).ready(function(){
              $( "#name" ).autocomplete({
                source: "&lt;?php echo site_url('admin/user/get_autocomplete/?');?&gt;"
              });
          });
      &lt;/script&gt;
  </code></pre>