2012-01-10 190 views
0

我在我的表單中使用jquery自動完成。從autocomplete選擇值後,我想獲取該值並傳入另一個jquery函數。根據選定的值,我需要在同一個文本框中添加另一個自動建議。jquery自動完成響應

$("#pickUpID").autocomplete("auto_suggest.php", { 
    width: 260, 
    matchContains: true, 
    //mustMatch: true, 
    //minChars: 0, 
    //multiple: true, 
    //highlight: false, 
    //multipleSeparator: ",", 
    selectFirst: false 
}); 

之後,我想獲取pickUpID的值併發送到另一個jquery函數。

+2

如果你表現出一些代碼 – Nobita 2012-01-10 12:00:54

回答

0

嘗試是這樣的:(未測試)

$("#pickUpID").autocomplete("auto_suggest.php", { 
    width: 260, 
    matchContains: true, 
    //mustMatch: true, 
    //minChars: 0, 
    //multiple: true, 
    //highlight: false, 
    //multipleSeparator: ",", 
    selectFirst: false 
}).result(function(event, data, formatted) { 
    // your function call 
    myFunction(data); 

    // update with another result 
    $(this).val('another computed value'); 
}) 

如文檔:http://docs.jquery.com/Plugins/Autocomplete/result#handler

+0

由於這將是有益的。正是我想要的。 – Viralk 2012-01-10 14:43:07