开发者

Using JQuery to refresh a second drop down List relating to the first drop down list

开发者 https://www.devze.com 2023-03-20 14:04 出处:网络
I have 2 drop down lists on my homepage: To firstly let the user select the \'County\' To secondly let the user select the \'Town\'- related to that County\'

I have 2 drop down lists on my homepage:

  • To firstly let the user select the 'County'
  • To secondly let the user select the 'Town'- related to that County'

The town is related to the County by relating the County's Name and the Town's Name.

What I want to be able to do is:

Once the visitor selects the 'County' some way, the second开发者_运维知识库 Drop Down refreshes only to reveal the towns that are related to the County within the database.

I would appreciate any help and coding examples for the SQL Queries and Refreshes etc..

Many thanks,


Javascript

Assuming that you have a CGI responsible for retrieve the data, you have the following workflow:

  1. The only visible dropdown list is the first one.
  2. When the user chooses the "county" you send a request to the CGI with the first value to retrieve all the possible "Tows".
  3. Then you populate your second dropdown list with the CGI answer and show it to the user.

CGI

It is not possible to show you the right query because I don't know your database. By the way, do you have any database? That is certainly the hard part (at least in my country it is hard to find one).

0

精彩评论

暂无评论...
验证码 换一张
取 消