onChange event

Discussion in 'ASP General' started by vinodkus@gmail.com, Aug 4, 2007.

  1. Guest

    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>
     
    , Aug 4, 2007
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Zeebra3
    Replies:
    5
    Views:
    5,159
    pelegk1
    Jul 15, 2007
  2. MDBloemker
    Replies:
    2
    Views:
    2,875
  3. Norm via DotNetMonster.com

    using the client side "onchange" event function

    Norm via DotNetMonster.com, Jun 15, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    4,890
    Norm via DotNetMonster.com
    Jun 15, 2005
  4. Chris  Ashley

    Onchange event - need to click out?

    Chris Ashley, Dec 6, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    729
    Karl Seguin
    Dec 6, 2005
  5. Vitthal Bhat

    OnChange() Event in Struts

    Vitthal Bhat, Feb 17, 2005, in forum: Java
    Replies:
    6
    Views:
    9,976
    augur
    Feb 19, 2005
Loading...

Share This Page