
Hi there, i have a program in JSP where i have 2 tables tbl1 which contains the "page" and tbl2 which contains most of the record, in my jsp page i have a one dropdown menu where the user can choose, i.e if the user select PAGE 1 in the dropdown menu, it will display all the content of tbl2 that has the value of PAGE 1 from tbl1. and it is working properly.
the problem is if the user select "View ALL Pages" it will dislay nothing. what i want to do is if the user select the "View ALL Page" from the dropdown menu it will display all the records from my database.
here is my code: index.jsp
</head>
<body>
<h1 style="color:red; text-align: center">Report Table</h1>
<br>
<FORM action="HomePage.jsp" method="get">
<table align="center">
<tr>
<th>Select Page</th><td><select name='pageName' onchange="showPageName(this.value)">
<option value="">-=Show All=-</option>
<%
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/error_page", "root", "password");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("Select * from pagename");
while (rs.next()) {
%>
<option value="<%=rs.getString(1)%>"><%=rs.getString(2)%></option>
<%
}
%>
</select>
</table>
<div id='page'>
</div>
</form>
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.