Pass dropdown Item to session variable

Discussion in 'ASP General' started by carmen, Apr 18, 2005.

  1. carmen

    carmen Guest

    I am using the code below to open another page depending on what is
    selected. This is working ok but I would like to streamline it so that I
    will hot have to create a page everytime a new category code is added. How
    can I pass the category code to another page as a variable after it is
    selected? That way I would only need one page that can be used for all
    categories.

    Thanks
    Carmen

    <select name="ListBoxURL" size="1" language="javascript"
    onchange="gotoLink(this.form);">
    <option selected>Open Report by Category Code
    <%
    While not rs.EOF
    %>
    <option
    value="Action_Items/<%=rs("category_code")%>_start.asp"><%=rs.fields("category_code")%>
    <%
    rs.MoveNext
    Wend
    rs.Close
    %>
    </select>
    </p>
    <script language="JavaScript">
    <!--
    function gotoLink(form) {
    var OptionIndex=form.ListBoxURL.selectedIndex;
    parent.location = form.ListBoxURL.options[OptionIndex].value;}
    //-->
    </script>
    carmen, Apr 18, 2005
    #1
    1. Advertising

  2. So, wait, you have files named category1_start.asp, category2_start.asp, and
    so on?

    This is what ASP is meant to overcome. Pass the category ID to your page
    and query the data accordingly.

    <select onchange="location.href='display.asp?catid='+this.value;">
    <% Do while not.....
    <option
    value="<%=rs("category_code")%>"><%=rs("category_code")%></option>

    And then on display.asp

    <%
    Dim catID
    catID = Request.Querystring("catid")
    %>

    And from there, query your database and get whatever it is you need to
    display based on the category ID that was passed.

    Ray at work



    "carmen" <carmen@iyahoo_Spam.com> wrote in message
    news:Oz%...
    > I am using the code below to open another page depending on what is
    > selected. This is working ok but I would like to streamline it so that I
    > will hot have to create a page everytime a new category code is added. How
    > can I pass the category code to another page as a variable after it is
    > selected? That way I would only need one page that can be used for all
    > categories.
    >
    > Thanks
    > Carmen
    >
    > <select name="ListBoxURL" size="1" language="javascript"
    > onchange="gotoLink(this.form);">
    > <option selected>Open Report by Category Code
    > <%
    > While not rs.EOF
    > %>
    > <option
    >

    value="Action_Items/<%=rs("category_code")%>_start.asp"><%=rs.fields("catego
    ry_code")%>
    > <%
    > rs.MoveNext
    > Wend
    > rs.Close
    > %>
    > </select>
    > </p>
    > <script language="JavaScript">
    > <!--
    > function gotoLink(form) {
    > var OptionIndex=form.ListBoxURL.selectedIndex;
    > parent.location = form.ListBoxURL.options[OptionIndex].value;}
    > //-->
    > </script>
    >
    >
    Ray Costanzo [MVP], Apr 18, 2005
    #2
    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. Replies:
    6
    Views:
    587
  2. chowchho
    Replies:
    7
    Views:
    629
    Patrice
    Mar 28, 2008
  3. Tricky
    Replies:
    0
    Views:
    574
    Tricky
    Mar 19, 2009
  4. Tricky
    Replies:
    0
    Views:
    997
    Tricky
    Mar 19, 2009
  5. Cathy
    Replies:
    0
    Views:
    94
    Cathy
    Jul 3, 2007
Loading...

Share This Page