Click here to Skip to main content
11,709,366 members (41,334 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Java J2EE JDBC MySQL JSP , +
This thing is really bothering me. How can I get my dropdown list from MySQL database and then submit it to another table in DataBase. I only know how to create a static dropdown with html and but how can I make it dynamic.

i have a table STATE in Database and Now i want to populate all the STATE name in the drop down list dynamicly then i have to save these STATES ID into another table as its ID's Refrence

Please give me the solution code for this..
thanks
Bipendra rana
Posted 24-Mar-13 23:11pm

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Hello Royal,

Following JSP code snippet will help you in creating a dynamic dropdown list.
<%@ taglib prefix="sql" uri="http://java.sun.com/jstl/sql" %>
<sql:query var="states">
SELECT * FROM state
</sql:query>
<form name="frmMain" id="frmMain" method="post" action="some.jsp">
    <select id="lstSelect" name="lstSelect" multiple size="10">
        <option value="SELECT">Select State</option>
<c:forEach var="state" items="${states.rows}">
        <option value="<c:out value="${state.state_code}"/>">
            <c:out value="${state.state_name}"/&gt;
        </option>
</c:forEach>
    </select>
</form>
  Permalink  
Comments
Royal ɐuɐɹ at 25-Mar-13 6:11am
   
ok thank you sir..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 580
1 OriginalGriff 250
2 Maciej Los 225
3 Peter Leow 219
4 Mika Wendelius 160
0 OriginalGriff 9,428
1 Sergey Alexandrovich Kryukov 9,027
2 CPallini 5,189
3 Maciej Los 4,991
4 Mika Wendelius 3,856


Advertise | Privacy | Mobile
Web01 | 2.8.150819.1 | Last Updated 25 Mar 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100