
hi i need two selection box .in 1 box all designation like manager, ceo etc , onclick on manager i should get list of managers names in second selection box.. like wise so on. from database eg: manager: sanjay ,amir , ram , mohan CEO: deepak , farooq

Here is a jsp application that retrieves data from the database and stored into first dropdown. If user click any option from the dropdown, the corresponding values will get displayed into another dropdown.
1)selDesg.jsp:
<%@page import="java.sql.*"%>
<html>
<head>
<script language="javascript" type="text/javascript">
var xmlHttp
var xmlHttp
function showEmp(str){
if (typeof XMLHttpRequest != "undefined"){
xmlHttp= new XMLHttpRequest();
}
else if (window.ActiveXObject){
xmlHttp= new ActiveXObject("Microsoft.XMLHTTP");
}
if (xmlHttp==null){
alert("Browser does not support XMLHTTP Request")
return;
}
var url="selEmp.jsp";
url +="?count=" +str;
xmlHttp.onreadystatechange = stateChange;
xmlHttp.open("GET", url, true);
xmlHttp.send(null);
}
function stateChange(){
if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
document.getElementById("emp").innerHTML=xmlHttp.responseText
}
}
</script>
</head>
<body>
<select name='desg' onchange="showEmp(this.value)">
<option value="none">Select</option>
<%
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("Select * from desg");
while(rs.next()){
%>
<option value="<%=rs.getString("DESG_NO")%>"><%=rs.getString("DESIGNATION")%></option>
<%
}
%>
</select>
<br>
<div id='emp'>
<select name='emp' >
<option value='-1'></option>
</select>
</div>
</body>
</html>
2)selEmp.jsp:
<%@page import="java.sql.*"%>
<%
String no=request.getParameter("count");
String buffer="<select name='emp' ><option value='-1'>Select</option>";
try{
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("Select * from emp where DESG_NO='"+no+"' ");
while(rs.next()){
buffer=buffer+"<option value='"+rs.getString("EMP_NAME")+"'>"+rs.getString("EMP_NAME")+"</option>";
}
buffer=buffer+"</select>";
response.getWriter().println(buffer);
}
catch(Exception e){
System.out.println(e);
}
%>
For the above code, we have used two database tables:
1)desg:
CREATE TABLE `desg` (
`DESG_NO` int(100) default NULL,
`DESIGNATION` varchar(255) default NULL
);
2)emp:
CREATE TABLE `emp` (
`EMP_NO` int(10) NOT NULL auto_increment,
`EMP_NAME` varchar(100) default NULL,
`DESIGNATION` varchar(100) default NULL,
`JOINING_DATE` date default NULL,
`SALARY` int(100) default NULL,
`DESG_NO` int(100) default NULL,
`DEPT_NAME` varchar(100) default NULL,
PRIMARY KEY (`EMP_NO`)
);
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.