I have the following two functions which are fired on different events:
$('.CCB').change(function (event) {
var matches = [];
$(".CCB:checked").each(function () {
matches.push(this.value);
});
alert(matches);
});
which is called when a check box item is checked and
$('#textBox').keydown(function (e) {
var code = e.keyCode ? e.keyCode : e.which;
var st = document.getElementById("textBox").value
if (code != 8) // if backspace is hit don't add it to the search term
{
st = st + String.fromCharCode(code);
}
else
{
st = st.substr(0, st.length - 1)
}
});
which is fired when the user types in a text box. Can I unite them in some way so when any of the actions is fired (either check box check or text box keydown) to get both the array with check box values and the string from the text box, so after that I can perform some custom logic on them?