Get all updates of Java4s
Follow Us: Email Newsletter

Country State Dropdown Example With AJAX/Servlets

Ajax » On Oct 25, 2011 { 15 Comments } 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

You Might Also Like

  ♦ About Author ♦

Java4s_Author
sivateja@java4s.com
Full Stack( Java/J2EE & UI/UX ) Developer and founder of Java4s - Get It Yourself, A popular Java/J2EE Programming Blog. Sign-up for the Email Newsletter for your daily dose of Java tutorials.

Comments

15 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 ..

  10. Ravi says:

    in my database(mysql) i’ll create emp name and image tables. when i choose particular name that related image will show in my html dropdown list how can i do it

  11. jugal says:

    hello,
    i am working in telecom service project and i am using mysql database.
    i have a table of city , state , zonal and branch
    and this all are the dropdown lists in the project
    if i select the state the other are automaticaly filled can i do this
    and in registration form these all the used as the foriegn keys … please give me the solution

    and tell me it is compul.. to use the ajax

  12. zoie says:

    thanks man its helpful for me

  13. shubham says:

    I have to implement this code in my project. But this code is showing some error. Sorry, but I don’t have knowledge of javascript but are the semicolons issue in the above program?

  14. hitesh mourya says:

    var urls=”http://www.java4s.com:2011/On_select_from_database_dropdown_Update_2/db_fetch.jsp?ok=”+keys
    Please explain this code.

  15. Thiga says:

    The second drop-down is empty.

Name*
Mail*
Website



By posting your answer, you agree to our comments policy.
What would you like to learn today?
Browse these popular technologies
Hibernate spring struts Servlets ajax Log4j jQuery Json Core Java Web Services AngularJs
Most Recent Tutorials
Hibernate_Logo Hibernate Recent Posts Spring_Logo Spring Recent Posts Struts_Logo Struts Recent Posts
Useful Links Current & UpComing Tutorials
Upcoming
  Web Services [ SOAP ], JSP
Contact | About Us | Privacy Policy | Advertise With Us

© 2010 - 2016 Java4s - Get It Yourself.
The content is copyrighted to Sivateja Kandula and may not be reproduced on other websites.