You must Sign In to post a response.
  • Category: [About DotNetSpider]

    Dependent dynamic dropdown list from database jsp

    Hi,

    I am trying dropdown list in jsp. first i am trying
    bind dropdown list with district and then Taluka. When I select
    district then automatically bind a taluka drop down list.
    So how to do this, kindly make change in following. so
    i can understand where is my mistake.

    <%
    Connection conn = DriverManager.getConnection("jdbc:sqlserver://localhost:1433;databaseName=GATEWAY", "sa", "allied007");
    Statement stmt = conn.createStatement();
    ResultSet rs = stmt.executeQuery("Select ID, DISTRICT From District_Master");

    Connection Talconn = DriverManager.getConnection("jdbc:sqlserver://localhost:1433;databaseName=GATEWAY", "sa", "allied007");
    Statement Talstmt = Talconn.createStatement();
    ResultSet Talrs = Talstmt.executeQuery("Select id, District_id, Taluka From Taluka_Master");
    %>


    <select id="ddlStateName" name="ddlStateName" class="columnwidth1">
    <option value="0" selected>Select</option>
    <% while (rs.next()) {%>
    <option value="<%=rs.getString("ID")%>"><%=rs.getString("DISTRICT")%></option>
    <% }%>
    </select>

    <select name="ddlTalukaName" class="columnwidth1">
    <option value="0">Select</option>
    <%
    while (Talrs.next()) {%>
    <option value="<%=Talrs.getString("ID")%>"><%=Talrs.getString("Taluka")%></option>
    <%}%>
    </select>
  • #766311
    Hi
    you can go through below links


    "roseindia.net/jsp/get-data-into-dropdownlist-database.shtml"
    "javatpoint.com/q/2241/how-can-i-retrieve-data-from-database-and-insert-those-records-into-a-drop-down-list-dynamically-using-jsp-?"

    Name : Dotnet Developer-2015
    Email Id :kumaraspcode2009@gmail.com

    'Not by might nor by power, but by my Spirit,' says the LORD Almighty.

  • #766326
    Hi,

    Refer below link this might be helpful to you, In this refer comment no 2 he is explaining how to get records from database and bind the same to dropdownlist using JSP.

    http://stackoverflow.com/questions/22550913/how-to-fetch-the-dropdown-values-from-database-and-display-in-jsp

    --------------------------------------------------------------------------------
    Give respect to your work, Instead of trying to impress your boss.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/


Sign In to post your comments