onChange event

V

vinodkus

I have two drop down. In first drop down it shows the state name and
in second drop down it shows city of that state. but i want if any
particular state is selected then its corresponding state should be
selected in another drop down. I think onchange event is require to
write on first drop down but i dont want to put any submit button. I
want if first drop down is selected then its corresponding data should
be displayed in another drop down.
<html>
<head>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<title>New Page 1</title>
</head>

<body>
<form name ="form" action="stateCity.asp" method=post>
<%
set con = Server.CreateObject("ADODB.Connection")
con.open "driver={SQL Server};server=c1;uid=sa;pwd=;database=pubs;"
set rs = con.execute("select distinct(statename) from stcity")
%>
<select name =st width=75>

<%
if not rs.eof then
while not rs.eof
%>
<option value="<%=rs(0)%>"><%=rs(0)%></option>
<%
rs.movenext
wend
end if
%>
</select>
<%
st = request.form("st")
%>
<select name=ct width=75 onChange='return st_change()'>
<%
set rs1 = con.execute("select city from stcity where statename =
'"&st&"'")
%>
<%
if not rs1.eof then
while not rs1.eof
%>
<option value="<%=rs1(0)%>"><%=rs1(0)%></option>
<%
rs1.movenext
wend
end if
%>
<script language="JavaScript">
<!--
function st_change()
{
form.submit();
}
-->
</script>
</select>
<input type = submit value = submit name=submit>
</form>
</body>
</html>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top