troubleshooting Question

Activate JQuery Autocomplete when a checkbox is clicked

Avatar of tuchfeld
tuchfeld asked on
JavaScriptAJAX
23 Comments1 Solution1979 ViewsLast Modified:
Hello,
I use JQuery Autocomplete,
Now I'd like that if the user click a Checkbox such as SearchIn_Book1 or SearchIn_Book2
See attached code.
I'd like to reactivatethe the JQuery Autocomplete (with the same existing input string (notice that the checkbox value is passed as parameter).
Thanks, Aryeh.
<SCRIPT type="text/javascript">
$(function() {
	$("#book_words").autocomplete("./Book_Search.aspx", {
		scroll: true,
		matchSubset: false,
		parse: function(data) {
			var parsed = [];
			var rows = eval(data);
			for (var i=0; i < rows.length; i++) {
				var row = $.trim(rows[i]);
				if (row) {
					parsed[parsed.length] = {
						data: rows[i],
						result: row
					};
				}
			}
			return parsed;
		},
		extraParams: {
			search_in: function() { var res = ""; if 

(document.getElementById("SearchIn_Book1").checked) res = "1"; if 

(document.getElementById("SearchIn_Book2").checked) res += "2"; return res; }
		},
		formatItem: function(row, i, n) {
			return row;
		}
	});
});
</SCRIPT>
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 23 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 23 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros