views:

30

answers:

0

I have a text field 1 which Iam trying to attach the autocomplete to that field when i enter the textfield1 value the request goes to php page and which accepts a parameter. and it should return the response .Iam not able to get the response .How do i get that

$("#txt1").autocomplete({
    source: "getpeople.php?term="+$("#txt1").attr("value"),
    minLength: 2,
    select: function(event, ui) {
        alert("Selct");
        var label= ui.item.label;
        var value= ui.item.value;
        $('#txt2').val(label.substr(value.length+1));
    },
    change: function(event, ui) { 
        alert("Change");
        if (jQuery.trim($('#txt1').val())=='') {
            $('#txt2').val('');
        }
    }   
});

when i start typing in that field a small spinning image runs in the textfield in a loop .How do i get rid of that.The Fetched value Should update in the txt2 .I mean autocomplete should get attached to txt2

How do i pass the JSON array in source to the select of input field