Wrox Programmer Forums
|
ASP Forms As of Oct 5, 2005, this forum is now locked. Please use "Classic ASP beginner" at http://p2p.wrox.com/forum.asp?FORUM_ID=54 or "Classic ASP Professional" http://p2p.wrox.com/forum.asp?FORUM_ID=56 instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP Forms section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 22nd, 2005, 03:34 PM
Authorized User
 
Join Date: Jan 2004
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to creative_eye
Default 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>&nbsp;</p>
<input type=submit>
</form>


 
Old January 22nd, 2005, 09:30 PM
Friend of Wrox
 
Join Date: Dec 2004
Posts: 307
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Vadivel Send a message via Yahoo to Vadivel
Default

Once the user selects the city ... while you are builing the page again you need set that value as selected in the city dropdown box.

Google for "Populating dropdown based on another dropdown" ... there are lots of links!!

Best Regards
Vadivel

MVP ASP/ASP.NET
http://vadivel.thinkingms.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
Many-To-Many Combo Problem SteveNaw VB.NET 2002/2003 Basics 3 July 19th, 2007 08:20 AM
Combo box problem diegoblin Beginning VB 6 2 October 4th, 2006 05:32 PM
Combo Box Problem munrrob Access 1 September 21st, 2006 10:35 AM
Problem Using Combo Boxes munrrob Access VBA 1 August 14th, 2006 12:50 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.