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
- <div class="label_div">Type Category</div>
- <input name="category1" type="text" id="category1" value="<?php echo $_POST['category1']; ?>" size="35" onkeyup="categoryscript1()" />
-
-
- <div class="input_container">
- <ul id="categorylist1">
- </ul>
- </div>
- </div>
- <!-- content -->
-
- <!-- footer -->
- </div>
My AJAX
- 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
-
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