Regarding Dynamic Drop Down list using Ajax With DWR
807589May 17 2008 — edited Jun 28 2008Hi...
For getting the values into combo box dynamically from the database i used DWR concept in ajax. Now i can able to get the values but i can't able to display the values, using the dwr/* i can able to see the values that are returned from the java method to one List.But i can able to display the values in another combo box using the following Javascript function:
function updateSizes(){
var num1=dwr.util.getValue("cid");
Demo.getEmp(num1, function(data) {
dwr.util.setValue("eid", data);
});
}
and my actual jsp page is:
<%@ page import="java.sql.*" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
<script type='text/javascript' src='/ajax upload/dwr/interface/Demo.js'></script>
<script type='text/javascript' src='/ajax upload/dwr/engine.js'></script>
<script type='text/javascript' src='/ajax upload/dwr/util.js'></script>
</head>
<body>
<%
try{
Class.forName("com.mysql.jdbc.Driver");
Connection con1=DriverManager.getConnection("jdbc:mysql://localhost:3306/cerp_project","root","root");
String vsqle="select * from Client_Details";
Statement stmte=con1.createStatement();
ResultSet rs=stmte.executeQuery(vsqle);
out.println("<table><tr><td>Client_ID:</td><td>");
out.println("<select name='cid' id='cid' onchange='updateSizes();'>");
while(rs.next())
{
int cuid=rs.getInt("Client_ID");
out.println("<option value="+cuid+">"+cuid+"</option>");
}
out.println("</select></td></tr>");
out.println("<tr><td>Employee Number:</td><td>");
out.println("<select name='eid' id='eid'>");
out.println("<option>Select size</option>");
out.println("</select></td></tr></table>");
con1.close();
}
catch(Exception e){
System.out.println("Error Is:"+e);
}
%>
</body>
</html>
please anybody help me regarding the solution for displaying in another combo box