我正在使用JQuery自動完成(jquery.autocomplete.js)。 我想知道如何在提交表單後選擇一個項目? 當前當某個物品被選中時,您必須按兩次輸入,一次到 將物品放入搜索字段,然後一次提交搜索。我想 喜歡提交搜索的第一個輸入或當一個項目選擇鼠標。JQuery自動完成和表單自動提交
我該如何使用它來提交表格? 這是我的代碼::
$(function() {
$("#artist").autocomplete({
source: function(request, response) {
$.ajax({
url: "http://",
dataType: "jsonp",
data: {
results: 12,
format:"jsonp",
name:request.term
},
這是形式::
<form id="mainSearchForm" onSubmit="ytvbp.listVideos(this.queryType.value, this.searchTerm.value, 1); document.forms.searchForm.searchTerm.value=this.searchTerm.value; ytvbp.hideMainSearch(); document.forms.searchForm.queryType.selectedIndex=this.queryType.selectedIndex; return false;">
<div align="left">
<select name="queryType" onChange="ytvbp.queryTypeChanged(this.value, this.form.searchTerm);">
<option value="all" selected="true">All Videos</option>
<option value="top_rated">Top Rated Videos</option>
<option value="most_viewed">Most Viewed Videos</option>
<option value="recently_featured">Recently Featured Videos</option>
</select>
<input name="searchTerm" id="artist" >
<input type="submit" value="Search">
</div>
</form>
安置自己的自動完成代碼 – Dunhamzzz
你可以用「平變化」,並提交表單。 – Dev