The same combo problem
I have written the following code. When the page loads, the first combo fills with the name of cities in the order wich is in the DB. When i select any city from the first combo, page goes refresh and the second combo fills with the Towns relating that particular city. But the problem is that everytime i select city it displays the first value as it is in the Db. And the second combo fills with the values (town names) related to the first value.
<script>
function doSubmit()
{
document.fSelect.action = "combo.asp"
document.fSelect.method ="post"
document.fSelect.submit();
}
</script>
</head>
<body>
<%
set con = Server.CreateObject("ADODB.Connection")
set Rs = Server.CreateObject("ADODB.Recordset")
Con.Open strConnect
SQL = "Select * FROM City"
Rs.Open SQL, Con, 1, 2
%>
<form name="fSelect" method="post" action="comboResult.asp">
<p> city
<select name="City" id="city" onchange="doSubmit()">
<% While Not Rs.EOF %>
<option value= <% = Rs.Fields("SNo")%>><% =Rs.Fields("City")%></option>
<%
Rs.MoveNext
Wend
%>
</select>
</p>
<%
If Request.Form("City") > 0 Then
strSQl= "select * from Towns where SNo=SNo"
Rs.close
Rs.open strsql, con
End If
%>
<p>town
<select name="town" id="town">
<% If Rs.RecordCount > 0 Then
While Not Rs.EOF %>
<option value=<% =Rs.Fields("Towns")%>><% =Rs.Fields("Towns")%></option>
<% Rs.Movenext
Wend
End if
%>
</select>
</p>
<p> </p>
<input type=submit>
</form>
|