Click here to Skip to main content
15,888,454 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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

1 solution

Hello Royal,

Following JSP code snippet will help you in creating a dynamic dropdown list.
Java
<%@ 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>
 
Share this answer
 
Comments
Royal ɐuɐɹ 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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900