| | |
Question - ASP + Ajax
Please support our ASP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
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
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
•
•
Join Date: Feb 2005
Posts: 86
Reputation:
Solved Threads: 3
You need to query the database using ajax get or post method, and then use callback to show the second dropdown menu using innerHTML.
Dexter Zaf
Ex-designz.net
Ex-designz.net
This is the code got, it works fine if I place a textbox instead of teh second drop-down.
main.asp file
execute.asp file
main.asp file
ASP Syntax (Toggle Plain Text)
<script type="text/javascript"> <!-- function myfunction() { var xmlhttp = false; //Check if we are using IE. try { //If the Javascript version is greater than 5. xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); alert ("You are using Microsoft Internet Explorer."); } catch (e) { //If not, then use the older active x object. try { //If we are using Internet Explorer. xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); alert ("You are using Microsoft Internet Explorer"); } catch (E) { //Else we must be using a non-IE browser. xmlhttp = false; } } //If we are using a non-IE browser, create a javascript instance of the object. if (!xmlhttp && typeof XMLHttpRequest != 'undefined') { xmlhttp = new XMLHttpRequest(); } abc = document.getElementById('txtname').value; var obj = document.getElementById('txtshouvik'); xmlhttp.open("GET", "execute.asp?str="+ abc); xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { obj.value = xmlhttp.responseText; } } xmlhttp.send(null); } //--> </script> <select name="txtCity" id="txtCity" onchange="javascript:myfunction();"> <% set rsCity = conn.execute("SELECT DISTINCT Venue_City from PRS_Master_Venue") do until rsCity.eof %> <option onclick="javascript:myfunction();"><%=rsCity("Venue_City")%></option> <% rsCity.movenext loop %> </select> <select name="txtCity" id="txtCity" onchange="javascript:myfunction();"> <option onclick="javascript:myfunction();"><%=rsCity("Venue_City")%></option> </select> <input name="btn" type="button" value="click" onClick="javascript:myfunction();"/>
execute.asp file
ASP Syntax (Toggle Plain Text)
<% response.Write "Venue Name here..." %>
![]() |
Similar Threads
- [For Hire] Php, Mysql, ASP, AJAX, DHTML programmer (Post your Resume)
- [For Hire] PHP, Mysql, ASP, AJAX, DHTML programer (Post your Resume)
- Ajax Question (ASP.NET)
- What is the best book to start with ASP.NET (ASP.NET)
- Question about ASp or Php (PHP)
- Question for ASP.NET/Mozilla Users...or anyone... (ASP.NET)
Other Threads in the ASP Forum
- Previous Thread: Leave System
- Next Thread: paging problem
| Thread Tools | Search this Thread |
archive asp asp.net aspandmssqlserver2005 aspandmssqlserver2005connection aspconnection connection database databaseconnection dreamweaver excel fso iis msmsql mssql2005 mssqlserver2005 mssqlserver2005andasp mssqlserverandasp opentextfile record searchbox selectoption single specfic sqlserver sqlserverconnection windows7





