Hwysnlernlkhb
New Member
so I have been at this for quite a while (over a week) searching google and stackoverflow and all that. Can't seem to get a compilation of information to make this work.[ASPX PAGE]\[code\] <span>Make</span> <asp:TextBox ID="Make_SearchBox" runat="server" ToolTip="Enter Make"></asp:TextBox> <span>Model</span> <asp:TextBox ID="Model_SearchBox" runat="server" ToolTip="Enter Model"></asp:TextBox>\[/code\][JavaScript]\[code\] <%--Autocomplete Function--%><script type="text/javascript"> var valuehttp://stackoverflow.com/questions/15627067/= ""; $(document).ready(function () { $("#PageContent_Make_SearchBox").autocomplete("/WebHandlers/AutoComplete.ashx",{ extraParams: { field: "Make" }, autoFill: false }); $("#PageContent_Model_SearchBox").autocomplete("/WebHandlers/AutoComplete.ashx", { extraParams: { field: "Model" }, autoFill: false }); }); </script>\[/code\][ASHX WEBHANDLER - C#]\[code\] public void ProcessRequest(HttpContext context) { // INITIALIZING NEEDED VARS string query = ""; string sql = ""; // CHECK "field" QUERY AND PASS TO SWITCH string field = context.Request.QueryString["field"]; if (field != null) { switch (field) { case "Make": query = context.Request.QueryString["q"]; sql = "Select DISTINCT Make from Vehicle Where Make LIKE '%" + query + "%'"; break; case "Model": query = context.Request.QueryString["q"]; sql = "Select DISTINCT Model from Vehicle Where Model LIKE '%" + query + "%' AND Make LIKE (((MAKE TEXTBOX VALUE))); break; } } string connStr = System.Configuration.ConfigurationManager.ConnectionStrings["ConnString"].ConnectionString; // CONNECT TO DATABASE, RUN QUERY AND RETURN DATA using (SqlConnection connection = new SqlConnection(connStr)) using (SqlCommand command = new SqlCommand(sql, connection)) { connection.Open(); using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { context.Response.Write(reader.GetString(0) + Environment.NewLine); } } } }\[/code\]The above works absolutely fine with the make text field. When I type "toy" in make field It passes like this:\[code\]GET http://localhost:26724/WebHandlers/AutoComplete.ashx?q=toy&field=Make\[/code\]What I want to do is after the user gets the make and starts writing in the model field it should search only the models pertaining to that make. The C# side of is is easy I suppose, just SQL query, but how do I get the JQuery to take the value of the make text field and add it to the query string.Note that it needs to grab the value of the make text box only after it is full not at $document.ready.Thank you all in advance. I will be sure to select a best answer.