i want to populated brand drop-down list and state drop-down list by changing on country drop-down list i mean according to country name there will be change in state names groups and brand name groups too... meaning that change in a single drop-down list changes into two dropdown list i hv donw this but i want both drop down will be in a new line how can i do this i m showing my codes here please help me
country.jsp
<%@page import="java.sql.*"%>
<html>
<head> <br />
<script language="javascript" type="text/javascript"> <br />
var xmlHttp <br />
var xmlHttp
function showState(str)
{
xmlHttp=GetXmlHttpObject();
if(xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
}</p>
var url="State.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("state").innerHTML=xmlHttp.responseText
}
}
function GetXmlHttpObject()
{
var xmlHttp=null;
try
{
xmlHttp=new XMLHttpRequest();
}
catch(e)
{
//Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}
</script>
</head>
<body>
<form action="StateSub.jsp" >
<select name='country' onchange="showState(this.value)">
<option value="none">Select Country</option>
<%
String id="";
String name= "";
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/shoppingcart","root","rat");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("Select * from country");
while(rs.next())
{
id=rs.getString(1);
name=rs.getString(2);
%>
<option value="<%=id%>"><%=name%></option>
<%
}
%>
</select>
<br>
<div id='state'>
Enter state
<select name='state' >
<option value='-1'></option>
</select>
Enter brand
<select name='brand' >
<option value='-1'></option>
</select>
</div>
<input type="submit"/>
</form>
</body>
</html>
state.jsp
<%@page import="java.sql.*"%>
<%
String country=request.getParameter("count");
System.out.println("State"+country);
String buffer="Enter state<select name='state' ><option value='-1'>Select state</option>"; <br />
try
{
String sid="";
String snam="";
String bid="";
String bnam="";
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/shoppingcart","root","rat");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("Select * from state where countryid='"+country+"' ");
while(rs.next())
{
sid=rs.getString(1);
snam= rs.getString(3);
buffer=buffer+"<option value='"+sid+"'>"+snam+"</option>";
}
buffer=buffer+"</select>";
String buffer1="Enter brand<select name='brand' ><option value='-1'>Select brand</option>";
Statement stmt1 = con.createStatement();
ResultSet rs1= stmt1.executeQuery("Select * from try where countryid='"+country+"' ");
while(rs1.next())
{
bid=rs1.getString(2);
bnam= rs1.getString(1);
buffer1=buffer1+"<option value='"+bid+"'>"+bnam+"</option>";
}
buffer1=buffer1+"</select>";
response.getWriter().print(buffer+"::\\\\n"+buffer1);
}
catch(Exception e)
{
System.out.println(e);
}
%>
StateSub.jsp
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'StateSub.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->