In the below 3 programs
In getcustomer.jsp iam getting details from database according to the selected item in listbox in customer.html
now i want to put those result values in second listbox in customer.html
how is it possible tell me
if possible provide related code to the below example
customer.html
<html>
<head>
<script src="selectcustomer.js"></script>
</head><body><form>
Select a Customer:
<select name="customers" onchange="showCustomer(this.value)">
<option value="BS101">BS101
<option value="BS102">BS102
<option value="BS103">BS103
</select>
<select>
<option>--select--</select>
</select>
</form><p>
<div id="txtHint"><b>Customer info will be listed here.</b></div>
</p></body>
</html>
selectcustomer.js
var xmlHttp
function showCustomer(str)
{
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
{
alert ("Your browser does not support AJAX!");
return;
}
var url="getcustomer.jsp";
url=url+"?q="+str;
//url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
function stateChanged()
{
if (xmlHttp.readyState==4)
{
alert(document.getElementById("txtHint").innerHTML=xmlHttp.responseText);
}
}
function GetXmlHttpObject()
{
var xmlHttp=null;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}
getcustomer.jsp
<%
Connection con;
con=dcon.getCon();
String q=request.getParameter("q");
System.out.println("q");
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select * from PHR_FIN_MST_BS where BS_CODE='"+q+"'");
%>
<table>
<%
System.out.println("hi1");
while(rs.next()){
System.out.println("hi2");
%>
<tr><td><b><%
System.out.println("hi3"+rs.getString(1));
%></b></td></tr>
<tr><td><b><%=(rs.getString(2))%></b></td></tr>
<tr><td><b><%=(rs.getString(3))%></b></td></tr>
<tr><td><b><%=(rs.getString(4))%></b></td></tr>
<tr><td><b><%=(rs.getString(5))%></b></td></tr>
<tr><td><b><%=(rs.getString(6))%></b></td></tr>
<tr><td><b><%=(rs.getString(7))%></b></td></tr>
<tr><td><b><%=(rs.getString(8))%></b></td></tr>
<%
}//while
st.close();
rs.close();
con.close();
%>
</table>
</body>
</html> Last edited by MattEvans : Feb 26th, 2008 at 2:07 pm. Reason: Use [code] tags around blocks of code.