two drop down list with javacript

Discussion in 'Javascript' started by weiwei, Nov 14, 2005.

  1. weiwei

    weiwei Guest

    <% Option Explicit %>
    <!--#include file="includes/conn.inc"-->
    <% Dim rds, ID %>
    <% Set rds = Server.CreateObject("ADODB.Recordset") %>
    <% rds.Open "select RecID, LocationName from Location ORDER BY
    LocationName", connStr, 3, 4 %>

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Test Location</title>
    <meta http-equiv="Content-Type" content="text/html;
    charset=iso-8859-1">
    <SCRIPT LANGUAGE="JavaScript">
    <!-- Begin
    function formHandler(form){
    var URL =
    document.form.location_name.options[document.form.location_name.selectedIndex].value;
    parent.mainframe.location.href = URL;
    }
    // End -->
    </SCRIPT>
    <SCRIPT LANGUAGE="JavaScript">
    <!-- Begin
    function formHandler(form1){
    var URL =
    document.form1.location_network.options[document.form1.location_network.selectedIndex].value;
    parent.mainframe.location.href = URL;
    }
    // End -->
    </SCRIPT>
    </HEAD>
    </head>

    <body bgcolor="ccccff">
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td width="19%">&nbsp;</td>
    <td width="55%"><font
    size="3"><strong>Location</strong></font></td>
    <td width="26%"><font size="3"><strong>Network
    Subnet</strong></font></td>
    </tr>
    </table>
    <br>
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td width="11%">&nbsp;</td>
    <td width="48%"><form name="form">
    <SELECT NAME="location_name" onChange="javascript:formHandler()"> <div
    align="center">
    <% Do While NOT rds.EOF %>
    <OPTION
    value="redirect_loc.asp?ID=<%=rds("RecID")%>"><%=rds.Fields("LocationName")%></option>
    <% rds.movenext %>
    <% Loop %>
    <%
    rds.Close
    Set rds = Nothing
    %>
    </form></td>
    <td width="41%"><form name="form1"><div align="center">
    <% Dim rsd %>
    <% Set rsd = Server.CreateObject("ADODB.Recordset") %>
    <% rsd.Open "select RecID, Network from Location ORDER BY
    Network", connStr, 3, 4 %>
    <SELECT NAME="location_network" onChange="javascript:formHandler()">
    <% Do While NOT rsd.EOF %>
    <OPTION
    value="redirect_network.asp?ID=<%=rsd("RecID")%>"><%=rsd.Fields("Network")%></option>
    <% rsd.movenext %>
    <% Loop %>
    <%
    rsd.Close
    Set rsd = Nothing
    %>
    </form></td>
    </tr>
    </table>
    </body>
    </html>
    weiwei, Nov 14, 2005
    #1
    1. Advertising

  2. weiwei

    web.dev Guest

    weiwei wrote:
    > <% Option Explicit %>
    > <!--#include file="includes/conn.inc"-->
    > <% Dim rds, ID %>
    > <% Set rds = Server.CreateObject("ADODB.Recordset") %>
    > <% rds.Open "select RecID, LocationName from Location ORDER BY
    > LocationName", connStr, 3, 4 %>
    >
    > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    > <html>
    > <head>
    > <title>Test Location</title>
    > <meta http-equiv="Content-Type" content="text/html;
    > charset=iso-8859-1">
    > <SCRIPT LANGUAGE="JavaScript">
    > <!-- Begin
    > function formHandler(form){
    > var URL =
    > document.form.location_name.options[document.form.location_name.selectedIndex].value;
    > parent.mainframe.location.href = URL;
    > }
    > // End -->
    > </SCRIPT>
    > <SCRIPT LANGUAGE="JavaScript">
    > <!-- Begin
    > function formHandler(form1){
    > var URL =
    > document.form1.location_network.options[document.form1.location_network.selectedIndex].value;
    > parent.mainframe.location.href = URL;
    > }
    > // End -->
    > </SCRIPT>
    > </HEAD>
    > </head>
    >
    > <body bgcolor="ccccff">
    > <table width="100%" border="0" cellspacing="0" cellpadding="0">
    > <tr>
    > <td width="19%">&nbsp;</td>
    > <td width="55%"><font
    > size="3"><strong>Location</strong></font></td>
    > <td width="26%"><font size="3"><strong>Network
    > Subnet</strong></font></td>
    > </tr>
    > </table>
    > <br>
    > <table width="100%" border="0" cellspacing="0" cellpadding="0">
    > <tr>
    > <td width="11%">&nbsp;</td>
    > <td width="48%"><form name="form">
    > <SELECT NAME="location_name" onChange="javascript:formHandler()"> <div
    > align="center">
    > <% Do While NOT rds.EOF %>
    > <OPTION
    > value="redirect_loc.asp?ID=<%=rds("RecID")%>"><%=rds.Fields("LocationName")%></option>
    > <% rds.movenext %>
    > <% Loop %>
    > <%
    > rds.Close
    > Set rds = Nothing
    > %>
    > </form></td>
    > <td width="41%"><form name="form1"><div align="center">
    > <% Dim rsd %>
    > <% Set rsd = Server.CreateObject("ADODB.Recordset") %>
    > <% rsd.Open "select RecID, Network from Location ORDER BY
    > Network", connStr, 3, 4 %>
    > <SELECT NAME="location_network" onChange="javascript:formHandler()">
    > <% Do While NOT rsd.EOF %>
    > <OPTION
    > value="redirect_network.asp?ID=<%=rsd("RecID")%>"><%=rsd.Fields("Network")%></option>
    > <% rsd.movenext %>
    > <% Loop %>
    > <%
    > rsd.Close
    > Set rsd = Nothing
    > %>
    > </form></td>
    > </tr>
    > </table>
    > </body>
    > </html>


    You know what would be really nice? :) If you provided us a question.
    Otherwise, what do you want this group to do with your code? Where's
    the problem? Otherwise, your html and your asp bits are useless.
    web.dev, Nov 14, 2005
    #2
    1. Advertising

  3. web.dev wrote:

    > weiwei wrote:
    >> [Fullquote]

    >
    > You know what would be really nice? :) [...]If you provided us a

    question.
    > Otherwise, what do you want this group to do with your code? Where's
    > the problem? Otherwise, your html and your asp bits are useless.
    Thomas 'PointedEars' Lahn, Nov 14, 2005
    #3
  4. weiwei

    web.dev Guest

    weiwei wrote:
    [snip]
    > <SCRIPT LANGUAGE="JavaScript">

    The language attribute is deprecated. Use type attribute instead:

    <script type = "text/javascript">

    > <!-- Begin

    HTML comment tags are unnecessary

    > function formHandler(form){

    ....
    > }
    > // End -->
    > </SCRIPT>
    > <SCRIPT LANGUAGE="JavaScript">
    > <!-- Begin
    > function formHandler(form1){

    ....
    > }
    > // End -->
    > </SCRIPT>

    You have two functions with the same name. The second function will
    override the first one. Give them two different names. Then change
    which function the onChange event handler calls.

    [snip]
    > <form name="form">
    > <SELECT NAME="location_name" onChange="javascript:formHandler()"> <div
    > align="center">
    > <% Do While NOT rds.EOF %>
    > <OPTION
    > value="redirect_loc.asp?ID=<%=rds("RecID")%>"><%=rds.Fields("LocationName")%></option>
    > <% rds.movenext %>
    > <% Loop %>
    > <%
    > rds.Close
    > Set rds = Nothing
    > %>

    Where is the closing </select> tag?
    > </form>


    ><form name="form1"><div align="center">
    > <% Dim rsd %>
    > <% Set rsd = Server.CreateObject("ADODB.Recordset") %>
    > <% rsd.Open "select RecID, Network from Location ORDER BY
    > Network", connStr, 3, 4 %>
    > <SELECT NAME="location_network" onChange="javascript:formHandler()">
    > <% Do While NOT rsd.EOF %>
    > <OPTION
    > value="redirect_network.asp?ID=<%=rsd("RecID")%>"><%=rsd.Fields("Network")%></option>
    > <% rsd.movenext %>
    > <% Loop %>
    > <%
    > rsd.Close
    > Set rsd = Nothing
    > %>

    Again, where is the closing </select> tag?

    [snip]

    Hopefully, this will fix the problem you had, whichever that may be.
    web.dev, Nov 14, 2005
    #4
  5. [Forget about my other, accidental posting if you still see it]

    web.dev wrote:

    > weiwei wrote:
    >> [about 80 lines of full quote snipped]

    >
    > You know what would be really nice? :)


    If you learned how to quote properly?

    <http://jibbering.com/faq/faq_notes/pots1.html>

    > If you provided us a question.


    Full ACK here.

    > [...] Otherwise, your html and your asp bits are useless.


    They are useless. If the problem deals with server-side scripting, the
    OP should show server-side JS code, not VBScript. If it deals with
    client-side scripting, which can be assumed here, the OP should show the
    code generated by the server, not the generating code on the server.


    PointedEars
    Thomas 'PointedEars' Lahn, Nov 14, 2005
    #5
    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. SirPoonga
    Replies:
    2
    Views:
    753
    Ben Strackany
    Jan 7, 2005
  2. weiwei
    Replies:
    0
    Views:
    1,009
    weiwei
    Jan 5, 2007
  3. msimmons
    Replies:
    0
    Views:
    470
    msimmons
    Jul 16, 2009
  4. weiwei
    Replies:
    2
    Views:
    141
  5. Replies:
    5
    Views:
    267
Loading...

Share This Page