Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to code the Country and State Drop down buttons in jsp

 
nalamati satyanarayana
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
Please help how to code the country and state drop down buttons in jsp
I am getting data from the database First i have to show all country list after According to the user selection i need to display the states in country.
Here i am using servlet class to connect the database for front end i am using jsp.


Satya
 
Anoop Krishnan
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is very easy

You can do it 2 ways.

1.On Server side
- Submit the country code to your jsp
- Use the country code get the list of states from the database
- Build the html pull down (<select></select>) in your jsp
2.On the client side
- When the user changes a country
- Make a remote scripting operation using AJAX (http://www.w3schools.com/ajax/default.asp). It is nothing but making a hidden http request to a jsp or servlet which should return the list of states for a given country
- Use the list and build the pull down using javascript (http://www.javascriptkit.com/javatutors/selectcontent.shtml)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic