title: How to assign an autocomplete value to a hidden field?
body: <p>i have created search using ajax , jquery . There im auto filtering category names from category table and category items from content tables in same auto-filter box . </p>
  
  <p>What i want is if auto-filter select value is category , value should assign to a category_id hidden field and if auto-filter select value is item name ignore the assigning an do the search. </p>
  
  <p>please advice me how to proceed this.</p>
  
  <p><strong>json</strong></p>
  
  <pre><code>$query="SELECT  b.title,b.id
  FROM sltdb_cddir_categories b
  WHERE  b.title like '%".$searchc."%' AND b.parent_id BETWEEN 84 AND 107 AND b.level=3
  UNION
  SELECT  a.title,  a.id
  FROM  sltdb_cddir_content a join
        sltdb_cddir_categories b
        on a.categories_id = b.id
  WHERE a.title like '%".$searchc."%'AND b.parent_id BETWEEN 84 AND 107 AND b.level=3
   ";
  
  
   $db -&gt; setQuery($query);
  // Load the results as a list of associated arrays.
  $results = $db -&gt; loadAssocList();
   $json=array();
   foreach ($results as $json_result) {
   $json[] = array(
       'value' =&gt; $json_result["id"],
  
      'label' =&gt;  $json_result["title"]
   );
  }
  
  
   echo json_encode($json);
  </code></pre>
  
  <p><strong>jquery and form</strong></p>
  
  <pre><code> jQuery(function(){
                jQuery("#searchc").autocomplete({
                    source:'product.php',
                      delay: 300 ,
  
                    minLength:1,
  
                    select: function(event, ui) {
                        jQuery('#categories_id').val(ui.item.value);
                    }
  
                });
  
            });
  </code></pre>
  
  <p> <p>Name</p>
                          </p>
  
  <pre><code>                &lt;td&gt;&lt;p&gt;Location&lt;/p&gt;
                      &lt;input type="text" id="addressc" name="address"  /&gt;&lt;/td&gt;
                       &lt;input type="hidden" id="categories_id" name="categories_id" value="" /&gt;
  </code></pre>