auto suggestion jquery ...how to store the id

auto suggestion jquery ...how to store the id

Dear sir

following code fills up the autosggest field and Click on name or selection
I want to store the id of the name selected in other filed so as to use it while storeing the details.

My html code

  1. <div class="label_div">Type Category</div>
  2.                         <input name="category1" type="text" id="category1" value="<?php echo $_POST['category1']; ?>" size="35"   onkeyup="categoryscript1()" />
  3.                         
  4.                             
  5.                           <div class="input_container">
  6.                             <ul id="categorylist1">
  7.                             </ul>
  8.                           </div>
  9.                           </div>
  10.                             <!-- content -->
  11.           
  12.                           <!-- footer -->
  13.                       </div>


My AJAX

  1. function categoryscript1() {
     
         var min_length = 0; // min caracters to display the autocomplete
        var keyword = $('#category1').val();
       
        //var option =$('input[name=option]:checked').val();
         
        if (keyword.length >= min_length) {
            $.ajax({
                url: 'category1autofill.php',
                type: 'POST',
                data: {keyword:keyword},
                success:function(data){
                    $('#categorylist1').show();
                    $('#categorylist1').html(data);
                }
            });
        } else {
            $('#categorylist1').hide();
        }
    }

    // set_item : this function will be executed when we select an item

  2. function set_item1(item) {
        // change input value
     
        $('#category1').val(item);
        // hide proposition list
        $('#categorylist1').hide();
    }



I want to store the id $rs['id'] or the id of the selected record  in afield so that I can use this id instead of name so as to save the record