Below is a script I have loaded into an HTML Form Web Part Filter. It is autopopulated with list items from a list called 'Companies'. I want the list item to be submitted upon select INSTEAD of the users having to select the item from dropdown, and then hit the 'submit' button. New to development, so thanks for being patient if this is an obvious or easy fix. Thanks for your help!
<script>
// Settings
var url = "https://<mydomain>/_vti_bin/listdata.svc/Companies()";
var field = "Title";
// Onload
$(document).ready(function () {
$("#mytags").autocomplete({
source: function (req, add) {
var suggestions = search(req.term, url, field);
add(suggestions);
}
});
});
// Search all the listitems by using the REST Service
// Value is the text that needs to be used in the query
// listurl is the listdata.svc url withouth the filter params
// field is the name of the field where the value in exists
function search(value, listurl, field) {
var coll = new Array();
var url =
listurl + "?$filter=startswith(" + field + ",'" + value + "')";
$.ajax({
cache: true,
type: "GET",
async: false,
dataType: "json",
url: url,
success: function (data) {
var results = data.d.results;
for (att in results) {
var object = results[att];
for (attt in object) {
if (attt == field) {
coll.push(object[attt]);
}
}
}
}
});
return coll
}
</script>
<div class="ui-widget">
<label for="mytags"> Companies</label>
<div onkeydown="javascript:if (event.keyCode == 13) _SFSUBMIT_">
<input id="mytags" name="mytags" input type="text"/>
<onchange="javascript:_SFSUBMIT_"/></div>