For Programmers: Free Programming Magazines  


Home > Archive > ASP > August 2007 > onChange event









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author onChange event
vinodkus@gmail.com

2007-08-04, 6:56 pm

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=p
ubs;"
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>

Jon Paal [MSMD]

2007-08-05, 6:56 pm

http://www.texaswebdevelopers.com/e...supplier_in.asp




Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com