Can view the tutorials best in Google Chrome, Mozilla Firefox, Opera, higher version of Internet Explorer

Country State Dropdown Example With AJAX/Servlets

Ajax » On Oct 25, 2011 By Sivateja

Folks this is similar to the country/state drop down using Ajax, i believe we have lot of examples regarding this country/state drop down so just would like to do little changes, so i converted into employee number and name. But total concept is exactly same…!

Files Required

  • index.html
  • db_fetch.jsp
  • web.xml

Index.html

db_fetch.jsp

web.xml

OutPut

Note: you must have classes12.jar, ojdbc14.jar in the lib folder of you application

Database

Check Output

Click here to check the output







By [ Java/J2EE Developer & Web Designer ]
Founder of Java4s.com - Indian, lives in United States. You can contact me at sivateja@java4s.com


Comments

9 Responses to “Country State Dropdown Example With AJAX/Servlets”
  1. Srinivas says:

    Hi
    For removing all options inside a select box
    instead of this
     function removeall()
        {
     
            var ct=document.dummy.sele2.length;
            for(i=ct; i>=0; i–)    {    
                document.dummy.sele2.options[i]=null;
                 }
        }

    you can use
    document.dummy.sele2.options.length=0
    this single line is enough

  2. Java4s says:

    @Srinivas

    May be you are correct, did you got exact output ?

  3. hello… i got the output but the second dropdown list is showing only one value whereas my DB(MS Access) is having multiple values…. how to get multiple values in second DDList?

  4. cherry says:

    sir, please explain in index.html line number 24 to 56 please explain

  5. koti says:

    in my database(mysql) i’ll create city,state and country tables. when i choose particular country that related state and city will show in my html dropdown list how can i do it

  6. maheswari says:

    In first dropdown i will get values.but in second dropdown empty values…request is not ging to dbfetch.jsp from firstdropdown.what is the problem please explain

  7. mdee says:

    pls can you please forward the code to my email its very important and av bin looking for this to implement in my project..PLS

  8. dileep says:

    How to use text box instead of Dropbox….
    please help me…

  9. Swathi says:

    Its working properly. I need extension of this . Means I want to display cities based on selected country and state. Can you help me out pls ..

Name*
Mail*
Website



By posting your answer, you agree to our comments policy.
Most Recent Tutorials
Hibernate Recent Posts
Spring Recent Posts
Struts Recent Posts
Recomandded Links Current & UpComing Tutorials Java4s.com
Tutorials Online :
spring Hibernate struts Json Ajax Log4j Log4j
coreJava Servlets


UpComing :
JSP, Web Services [ In Progress ]
Java4s is optimized for learning java technologies, all the examples in this site are constantly reviewed to avoid errors. While using this site you agree to have read and accepted our terms of use and privacy policy
Especially i have prepared this blog by keeping fresher's in mind, however it will be very useful for real time developers too.


© 2014 Java4s All rights reserved. | strPro4Tut v(2.0) Theme designed by Team Java4s.