Hi all

I am creating an application for registration form where if user select a city from the drop down list box in the state list box corresponding state should be selected automatically.

Please help me ..., its very urgent


6 Years
Discussion Span
Last Post by arunp_eagle

Not clear what your requirement is. Selecting state from the drop down should make selected what?


thanks for ur reply
there is a list box with various cities and another list box is for states.Whenever i select a city from the list corresponding state should be selected automatically in the state list box.

thanks again!



iam a cpp developer.. i dont have indepth knowledge in js.
though i can give u the logic!

i got to know this from my colleague and replying you!

1. while declaring each items for the city combo box, maintain one custom variable and give it a number say for chennai, while declaring this option item, ,assign it a number say id = 1.
2. similaryly for all the cities that comes inside tamilnadu maintain the same id (i.e 1).
3. similaryly while delcaring the option items for the state combo-box, maintain the same numbers.
For example : while declaring tamilnadu option-item, assign it the number 1.
4. hence in the onchange event of the city combo box, get the option-item's number you have specified. (if you choosing chennai, the number you specified is 1, get that in a variable)
5. now iterate the numbers you have maintained for the states, and whichever state corresponds to this number, set that as the selected item in the state combo-box.

hence you can have like this:

cities :

chennai - 1
coimbatore - 1
bangalore - 2
mumbai - 3

tamilnadu - 1
karnataka - 2
maharashtra - 3

hope it will help you!

Arun P.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.