I have 2 AutoCompleteTextBoxes in my ASP.Net page. I need the 2nd textbox to get the value from the first box and assign it as one of the options to pull up the list. Client-side only.
$("#txtBox1").AutoCompleteTextBox({ type: "val1", minLength: "3", userid: '1234' });
$("#txtBox2").AutoCompleteTextBox({ type: "val2", minLength: "3", userid: '1234',
cc: $('#txtBox1').on('autocompletechange change', function () {
//alert(this.value);
return this.value;
})
});
So, cc needs to get the value selected in txtBox1 and popup the list of values returned from the sql proc. I tried text() and val() after the function. The alert works and has the value. But the end result is '' getting sent to the AJAX. I even tried a knockout variable attached to a label and tried
<%=lblTxtBox1.Text%>
But it's not working. All I need is for the options going to the AJAX call to look like
cc: 'abcd'
Any help is appreciated. Thanks much.
RESOLVED!
I needed a keyup event. I also indexed the table on the search fields as the response was very slow.
var cc = '';
$('#txtBox1').on('focusout', function() {
cc = this.value.toString();
});
var cc = this.value; // this will also work
$("#txtBox2").on('keyup', function() {
$("#txtBox2").AutoCompleteTextBox({ type: "type2", minLength: "3", userid: '1234', ccode: '' + cc + '' });
});