apapanic
asked on
Use 2 combo boxes to correspond with eachother
I need 2 combo boxes to correspond with eachother on my JSP page. If a user picks a selection from "combobox1" I want my SQL query that is embedded in a "DataHandler" class file to use that value to populate "combobox2" which is in the same JSP page.
this is what I have in my JSP page so far.....
I've set up a combo box for one of them to show where everything is coming from, and the format to kind of follow.
What I want it to do is when the first combo box changes, I want the second (new) combo box to populate, according to what the value (getuserid()) is in the first combo box.......
<html>
<head>
<title>EmailCombo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_openBrWindow(theURL,win Name,featu res) { //v2.0
window.open(theURL,winName ,features) ;
}
//-->
</script>
</head>
<body>
<font size="4" face="Arial, Helvetica, sans-serif"></strong>
<div align=center>Deliverable Evaluation Form: Document </div>
<font size="2">
<p> </p>
<hr size="5" align="center" noshade>
<strong>Section 1: Agency and Task Information</strong>
<%@page import="bah.arl.util.*" %>
<%@page import="bah.arl.evaluation s.*" %>
<%@page import="bah.arl.evaluation s.servlet. *" %>
<%@page import="java.util.*" %>
<%@page import="java.sql.*" %>
<%
try
{
Properties props = new Properties();
//DataHandler class connects to my database//
DataHandler dataHandler = new DataHandler(getServletCont ext().getI nitParamet er("abc"), getServletContext().getIni tParameter ("dbName") , "user1", "user1");
//This ArrayList is set up as a query in my DataHandler class... SELECT * FROM USERS
ArrayList emails = dataHandler.getAllUserids( );
//This is actually a servlet "evaluationsSessionBean that sets Userids...
evaluationsSessionBean evaluationsSessionBean = new evaluationsSessionBean();
evaluationsSessionBean.set Userids(em ails);
session.setAttribute("eval uationsSes sion", evaluationsSessionBean);
%>
<form name="reqForm" method="post" action="http://localhost:8080/evaluations/evaluations.jsp?requestType=1" target="docEvaluation.jsp" >
<p>
<table border="0" width="25%">
<tr><td><font size="2">Choose Your Agency:</font></td>
<td>
<select name="agencyID">
</p>
<%
Iterator emailsIter = emails.iterator();
while(emailsIter.hasNext() )
{
UserIDs currUser = (UserIDs)emailsIter.next() ;
%>
<option value="<%=currUser.getuser id()%>"><% =currUser. getuserid( )%></optio n>
<%
}
%>
</select></td></tr>
<%
}
catch(Exception err)
{
err.printStackTrace();
out.println("what\n");
}
%>
</tr></table>
<p> </p>
<p> </p>
<input type="submit" name="systemButton" value="Submit">
<input type="reset" name="clearForm" value="Reset">
</p>
</form>
</font>
</body>
</html>
this is what I have in my JSP page so far.....
I've set up a combo box for one of them to show where everything is coming from, and the format to kind of follow.
What I want it to do is when the first combo box changes, I want the second (new) combo box to populate, according to what the value (getuserid()) is in the first combo box.......
<html>
<head>
<title>EmailCombo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_openBrWindow(theURL,win
window.open(theURL,winName
}
//-->
</script>
</head>
<body>
<font size="4" face="Arial, Helvetica, sans-serif"></strong>
<div align=center>Deliverable Evaluation Form: Document </div>
<font size="2">
<p> </p>
<hr size="5" align="center" noshade>
<strong>Section 1: Agency and Task Information</strong>
<%@page import="bah.arl.util.*" %>
<%@page import="bah.arl.evaluation
<%@page import="bah.arl.evaluation
<%@page import="java.util.*" %>
<%@page import="java.sql.*" %>
<%
try
{
Properties props = new Properties();
//DataHandler class connects to my database//
DataHandler dataHandler = new DataHandler(getServletCont
//This ArrayList is set up as a query in my DataHandler class... SELECT * FROM USERS
ArrayList emails = dataHandler.getAllUserids(
//This is actually a servlet "evaluationsSessionBean that sets Userids...
evaluationsSessionBean evaluationsSessionBean = new evaluationsSessionBean();
evaluationsSessionBean.set
session.setAttribute("eval
%>
<form name="reqForm" method="post" action="http://localhost:8080/evaluations/evaluations.jsp?requestType=1" target="docEvaluation.jsp"
<p>
<table border="0" width="25%">
<tr><td><font size="2">Choose Your Agency:</font></td>
<td>
<select name="agencyID">
</p>
<%
Iterator emailsIter = emails.iterator();
while(emailsIter.hasNext()
{
UserIDs currUser = (UserIDs)emailsIter.next()
%>
<option value="<%=currUser.getuser
<%
}
%>
</select></td></tr>
<%
}
catch(Exception err)
{
err.printStackTrace();
out.println("what\n");
}
%>
</tr></table>
<p> </p>
<p> </p>
<input type="submit" name="systemButton" value="Submit">
<input type="reset" name="clearForm" value="Reset">
</p>
</form>
</font>
</body>
</html>
ASKER
It is similar, can you answer the first question?
You will have to use javascript at some level for doing this...
either like suggested in the other question, or by adding a onChange event to the 1st combobox so that it posts the form to the server again, which can set the values for the second combo box.
you can add a hidden field to the form, which a javascript method can set to "populate" when the combobox is changed and then the server can get this field, and if it has the value "populate", it can fil in the second combo box dependant on the value of the first one, and send this new HTML page to the user.
But that is the only way I can think of doing it that will work across multiple browsers...
Tim
either like suggested in the other question, or by adding a onChange event to the 1st combobox so that it posts the form to the server again, which can set the values for the second combo box.
you can add a hidden field to the form, which a javascript method can set to "populate" when the combobox is changed and then the server can get this field, and if it has the value "populate", it can fil in the second combo box dependant on the value of the first one, and send this new HTML page to the user.
But that is the only way I can think of doing it that will work across multiple browsers...
Tim
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Javascript is the easiest way to do this... But you should really sort out the first question before asking the same thing again...