我正在使用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