Question - ASP + Ajax Hey! Not sure if this is the correct section to post this. Well, I have a table in my sql server 2000 database *************** tblAddress ---------------------------- City_Name (varchar) Venue_Name (varchar) ******************* The "City_Name" column contains all the name of the cities in my country and each city has multiple venues. Now I have 2 drop-down boxes in my asp page. The first drop-down is already listed with all the cities which are in the "City_Name" column. What I now want is, when I select a city name from the first drop-down, the second drop down should be populated with all the venue names of that city (of course without refreshing the page) I know this can be done with ajax. I got few codes while googling but none of them are working
Are you using asp.net, or classic? If .NET go and the AJAX sdk from www.asp.net, it makes this stuff soooooo easy even I can do it. Jay
It's possible in ASP, but considerable work. I would have a look at learnasp.com, i think there is an article there about doing something similar to this.
Hello, I have develop similar thing in asp & ajax. If you want can help you PM me the details of your table(full tabel details)....I will return you the code....
You just wanna call a js function from onchange() for the City_Name drop-down. In that function get City_Name.value and use ajax to pass it to an asp with City_Name.value as a parameter like "getvenue.asp?city=" + City_Name.value Use Request.QueryString("city") to get the city in the ASP file. Use that value to generate a query, something like.... Dim sSql sSql = "SELECT * FROM venues WHERE city='" & Request.QueryString("city") & "';" Then you can loop over your recordset and spit out the html for your second drop down... response.write "<select name='venue'>" oRS.MoveFirst() Do While oRS.EOF = False response.write "<option value='" & oRS("venue") & "' selected>" & oRS("venue") & "</option>" Loop response.write "</select>" Then, in your html code put a wrapper div around where you want your second drop-down to go and give an id. say...'venue' Lastly in the callback you specified for your xmlobject (you did set a callaback function and use "GET" as a parameter?) just do some javascript like if (xmlHttp.readyState==4) { GetElementById(''venue'').innerHTML= xmlHttp.responseText; xmlHttp=null; } And Tada! You can create a server-side to create xml right from query using MSXML.DOMDocument. And output that. then in your javascript callback function use var xmldoc = xmlHttp2.responseXML; // notice the use of responseXML and parse as xml.