user1012082
user1012082

Reputation: 11

To populate dependent drop down in classic asp

I am working on classic asp and i need to populate drop downs.During page load,all continents,all countries and all cities should get populated in their respective drop downs.Also,once i select say Asia(continent drop dwn),countries in Asia should get populated in country drop down and all cities of Asia in city drop down.and once i select a specific country from country drop down,say India.,all cities belonging to India should get populated in the city drop down.

I have a sql proc which returns the results from DB.How do I populate the same drop down without reloading the page?Is there any solution using javascript?

Upvotes: 1

Views: 2918

Answers (4)

This requires a lot of data to be loaded internally when the page is loaded. Countries and cities do not change so the data is static. Simply use include files.

The way we did stuff like this was to use onchange javascript and javascript arrays. You create on array for your countries and then a separate city array for each country. When the onChange event happens on the country you fire off another javascript routine that rebuilds the dropdown using the appropriate javascript city array.

Upvotes: 1

StephenCollins
StephenCollins

Reputation: 805

You can't do this in classic ASP without a page reload. If you don't know how to do it in javascript, you can just have the first drop down, and then move to the next page adding the next drop down in the chain after a selection is made.

What I would do, is build the first drop down and on change, fire off some AJAX to hit an another ASP page to get the next drop down and then add it to the page.

jQuery would probably handle this pretty easy.

Upvotes: 0

Joel Spolsky
Joel Spolsky

Reputation: 33677

In Classic ASP:

  • Build the dropdowns using a simple for loop on the server which generates each of the <option> tags of the <select>.
  • Add JavaScript to the client page which detects the change in one dropdown (e.g. continent) and filters the <select> at run time, on the client side.

Upvotes: 0

Dave
Dave

Reputation: 4597

Well, I think AJAX was the solution to that problem. Sorry.


In response to comment: google gives me this.

Upvotes: 0

Related Questions