Greetings,
Im a newbie to JSP/Javascript (unfortunalley).
However I found enough example to create code that connects to my access db and populates two combo boxes.
The selection of the first box is used to populate the second (cascading).
See code below, apologies for the formatting as I wrote it in notepad.
I am assuming the code runs through once and therefor combo box populated only once.
How can I make them dynamic, needing some how to perhaps include a loop?
Preferrably without the use of arrays and with a simple structure as below, so I can understand it.
<!-- the % tag below is what is called a scriptlet tag - allows java to be embedded in the jsp -->
<%@ page import="java.util.*" %>
<%@ page language="java" %>
<%@ page import="java.sql.*" %>
<HTML>
<H1>FAQ</H1>
<H3>Please choose a category</H3>
<FORM ACTION="wk465682UserMenu.jsp" METHOD="POST">
<%
String CategoryCombo = null;%>
<SELECT NAME="Category" id = Category>
<%
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
Connection conn = DriverManager.getConnection("jdbc:odbc:FAQ");
Statement statement = conn.createStatement();
ResultSet rs = statement.executeQuery("SELECT DISTINCT CATEGORY FROM FAQ" );
while(rs.next()) {
CategoryCombo = rs.getString("Category");%>
<OPTION><%out.println(CategoryCombo);%>
</OPTION>
<% } %>
</SELECT>
<BR><BR>
<H3>Please choose a question</H3>
<%
String QuestionCombo = null;%>
<SELECT NAME="Question" id = Question>
<%ResultSet ss = statement.executeQuery("SELECT * FROM FAQ WHERE CATEGORY = ( '" + CategoryCombo + "')");
while(ss.next()) {
QuestionCombo = ss.getString("Question");%>
<OPTION><%out.println(QuestionCombo);%>
</OPTION>
<% } %>
</SELECT>
</FORM>
</HTML>
Thanks and hope this makes sense
Rob
oopps Thats should be beginner not begginer in subject heading!