I love jQuery. I work with it quite a lot on various projects. One of the coolest features in my humble opinion is AutoComplete. There are a ton of different plugins you can work with, some are variations of others, but for the most part, they work pretty darn good out of the box.
I have been trying unsuccessfully over the past hour or so to pass in the value of a checkbox as a parameter to my AutoComplete plugin as follows:
1 2 3 4 5 | cacheLength:0, minChars:2, max:20, autoFill:false, extraParams: { active : $('input[name=status]').is(':checked') } |
Now the issue I was encountering was regardless of what the state of the checkbox was, checked or unchecked, the AutoComplete plugin always returned it’s initial value. So if by default it was unchecked, it always returned false. If by default it was checked, it always returned true.
After a bit of digging, I finally stumbled across this site that explains that the value is locked in once the AutoComplete plugin is initialized: http://stackoverflow.com/questions/1216222/jquery-passing-checkbox-values
So to solve the issue:
1 2 3 4 5 6 7 8 9 | cacheLength:0, minChars:2, max:20, autoFill:false, extraParams: { active : function() { return $('input[name=status]').is(':checked'); } } |
Awesome! Thanks to Stack Overflow and redsquare!





[...] JQuery Autocomplete extraParams and CheckBoxes This post covers a problem where the developer was having problems passing the value of a checkbox as a parameter to their AutoComplete plugin. The problem was that the checkbox always returned the initial state value rather than the selected value. If you’ve run into this or are dealing with it now, this post should help you out. [...]
[...] JQuery AutoComplete extraParams and CheckBoxes [...]
[...] 9.JQuery Autocomplete extraParams and CheckBoxes This post covers a problem where the developer was having problems passing the value of a checkbox as a parameter to their AutoComplete plugin. The problem was that the checkbox always returned the initial state value rather than the selected value. If you’ve run into this or are dealing with it now, this post should help you out. [...]
[...] JQuery Autocomplete extraParams and CheckBoxes This post covers a problem where the developer was having problems passing the value of a checkbox as a parameter to their AutoComplete plugin. The problem was that the checkbox always returned the initial state value rather than the selected value. If you’ve run into this or are dealing with it now, this post should help you out. [...]