AJAX下拉菜单(国家,州,市) [英] ajax dropdown(country, state, city)

查看:235
本文介绍了AJAX下拉菜单(国家,州,市)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一些Ajax code做一些功能的下拉。

I need some ajax code to do some functions with drop down.

我有三个表值之一的国家,当时的国家和城市。

I have three table of values one for country, then state and city.

和我有三个下拉菜单来显示这些值

And i have three dropdown to show these values

首先,它应该显示

选择国家

选择状态

选择城市

在分别的下拉菜单(看中)。

in that drop downs(slect) respectively.

当我从第一个下拉菜单中选择美国

when i select united states from the first dropdown

在第二个下拉它必须显示美国的状态。

in the second drop down it must show the states of the united states.

和当我再次从国家下拉列表中选择一个状态

and again when i select a state from the state dropdown

就必须证明国家的城市在第三下拉列表(市)

it must show the cities of that state in the third dropdown(city)

我想与阿贾克斯做到这一点。

I want to do this with ajax.

任何一个可以有一个code做到这一点。

can any one have a code to do this.

请帮我。

感谢

推荐答案

1)创建3个表中的分贝

1) create 3 tables in db

country table
==============
countryId || countryName

stateTable
=============
stateId || stateName || countryName

city table
=============
cityId || cityName || stateId

2)现在创建3个Web服务 它发送数据的JSON格式

2) now create 3 webservices which sends data in json format

3)现在html页面 创建三个选择框,并结合每个选择框onchange事件(除了城市选择),该事件将发送countryId为的getStates Webservcie和STATEID为getCities web服务。并结合收到的JSON国国家选择框,市城市选择框

3) now on html page create three select box and bind onchange event on each select box (except for city select), that event will send countryId for getStates Webservcie and stateId for getCities webservice. and bind received json states in state select box and cities in city select box

这篇关于AJAX下拉菜单(国家,州,市)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆