Get all updates of Java4s
Newsletter

Ajax,jQuery Auto Fill Dropdown On Page Load

Ajax »on Oct 25, 2011 { 2 Comments } By Sivateja

Let us see the auto fill drop downs using Ajax and jQuery

Files Required

  • index.html
  • db_fetch.jsp
  • jquery-1.2.6.js (Add this jquery file at db_fetch.jsp location, same  folder)
  • web.xml

Index.html

Notes: See line number 6 in index.html ,$(document).ready(function() means we no need to send any request like onchange or onclick, once the page loads automatically the code in this $(document).ready(function() block will be executed, so indirectly we are calling this function on page load hope you are clear.

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 the Author .::

Java4s_Author
- Full Stack Java/J2EE & UI Web Developer
Founder of Java4s - Get It Yourself, A popular Java/J2EE Programming Blog, Love Java and UI frameworks.
You can sign-up for the Email Newsletter for your daily dose of Java tutorials.

Comments

2 Responses to “Ajax,jQuery Auto Fill Dropdown On Page Load”
  1. mahendra says:

    Sir,
    ” document.createElement(“OPTION”);” here you didn’t mention any element id then how could it create option element for second drop down list.

    Thanks & Regards
    Mahendra
    9160883581

  2. prasad says:

    here element is created dynamically.
    so, to create element dynamically there is no need of element id.
    it was created by using tagname “option”.
    Ex:
    to create button dynamically we use

    document.createElement(“button”);
    then button created dynamically.

    from: Prasad.k

Name*
Mail*
Website



By posting your answer, you agree to our comments policy.
What would you like to learn today?
Browse these popular technologies
Spring-Boot-tutorials Hibernate tutorials Spring tutorials Struts tutorials Servlets tutorials Ajax tutorials Log4j tutorials jQuery tutorials Json tutorials Core Java tutorials Web Services tutorials AngularJs tutorials
Most Recent Tutorials
Hibernate_Logo Hibernate Recent Posts Spring_Logo Spring Recent Posts Struts_Logo Struts Recent Posts
Contact | About Us | Privacy Policy | Advertise With Us

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