Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 14th, 2007, 02:07 AM
Authorized User
 
Join Date: Oct 2006
Location: New Delhi, Delhi, India.
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Default Question - ASP + Ajax

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 :(




-----------------------------------------------
www.chargertek.in - Cheapest WebHosting
__________________
-----------------------------------------------
www.chargertek.in - Cheapest WebHosting
Reply With Quote
  #2 (permalink)  
Old June 17th, 2007, 11:51 AM
Registered User
 
Join Date: May 2007
Location: Worcester, None, United Kingdom.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Banksie
Default

If i was doing that in normal asp, i would have a table for each city, containing the venue, and then a table of cities, this would then be related in my access database, then just select them from tables, but im sure there is a easier, faster way to do that!

Im can't really help as im not a ajax user.
But theres a idea for you to think about!

Banksie
Reply With Quote
  #3 (permalink)  
Old July 30th, 2007, 03:29 PM
Friend of Wrox
 
Join Date: Sep 2003
Location: Minneapolis, MN, USA.
Posts: 171
Thanks: 0
Thanked 1 Time in 1 Post
Default

Well Banksie you'd be totally UNnormalizing your data by doing it that way.

The process can be done without reloading the page, but will require some javascript and the XMLHttpRequest object. Here is a quick and dirty tutorial.

1) Create 3 pages (Form.asp, Cities.asp, Venues.asp).

2) Form.asp will include two divs (e.g. divCities, divVenues) as well as functions for "GetCities()" and "GetVenues()" in the <HEAD> section of the page.

3) Cities.asp will contain the HTML output for a dropdown called "CityId". The CityId dropdown will call the second function when changed and must pass the CityId and target div to the function as well.

4) Venues.asp will contain the HTML output for a dropdown called "VenueId".

5) In the onload event handler for Form.asp, call the first function, and pass two values for the source and target divs. For example, onload="GetCities('Cities.asp', 'divCities')". The function will make an XML request to the server returning the "Cities.asp" page into the "divCities" div without reloading the page.

6) When the option for the "CityId" dropdown is changed, the Venues function will be called. For example, onchange="GetVenues('Venues.asp?CityId=123', 'divVenues')". Notice the CityId within the values being passed to the GetVenues() function. The function will make an XML request to the server returning the "Venues.asp" page into the "divVenues" div without reloading the page.

If you need a sample of the functions or page structure just say the word and I'll try and put something together.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Ajax question stu9820 Ajax 5 June 17th, 2008 01:25 PM
Asp.net ajax everest General .NET 0 March 8th, 2007 12:21 AM
Ajax Security Question! evogli Ajax 1 November 2nd, 2006 05:46 AM
AJAX Using ASP sethumail2000 BOOK: Professional Ajax ISBN: 978-0-471-77778-6 0 March 7th, 2006 12:29 AM
using AJAX in ASP.Net muskaanbajaj ASP.NET 1.0 and 1.1 Professional 3 February 24th, 2006 05:38 AM



All times are GMT -4. The time now is 02:13 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.