Menu List

Discussion in 'ASP General' started by Lina Manjarres, Jul 20, 2005.

  1. Hello,

    I have a form page in ASP where the first menu/list function as a filter of
    the second menu list. Once I select an item form the first combo I get the
    second menu full of options. This is correct. My probem is that the first
    combo gets the default value again and I do not see what I did choose.

    I do not know if I explained this correctly. Hope someone can understand me.

    Thanks a lot, Lina
    Lina Manjarres, Jul 20, 2005
    #1
    1. Advertising

  2. Show the code you're using to populate the first drop down and the code
    you're using to retrieve that value.

    Ray at work

    "Lina Manjarres" <> wrote in message
    news:...
    > Hello,
    >
    > I have a form page in ASP where the first menu/list function as a filter

    of
    > the second menu list. Once I select an item form the first combo I get the
    > second menu full of options. This is correct. My probem is that the first
    > combo gets the default value again and I do not see what I did choose.
    >
    > I do not know if I explained this correctly. Hope someone can understand

    me.
    >
    > Thanks a lot, Lina
    Ray Costanzo [MVP], Jul 20, 2005
    #2
    1. Advertising

  3. This is the function code tu fill the combos, wher vector is a variable Pais
    filled with a recorset.

    Function ComboRS(vector)
    'Pinto el combo
    for i= 0 to UBound(vector, 2)
    Response.Write "<option value='"& vector(0,i) &" - "& vector(1,i)&"'>"&
    vector(0,i) &" - "& vector(1,i) & vbCrLf
    next
    End Function


    %>


    Here is the call to the recordset and the way I fill the variable Pais:

    strPais = "select IdPais, NmPais from Paises order by NmPais"
    Call OpenRS(rsPais,strPais,ConnAxs)
    Pais = rsPais.GetRows
    Call CloseRS(rsPais)

    If request.form("CboPais") = "" Then
    CadenaPais = "57"
    Else
    Izquierda = instr(1,request.form("CboPais"),"-")
    CadenaPAis = Trim(Left(request.form("CboPais"),Izquierda - 1))
    End If

    Here is how I work out the first combo:

    '<select name="cboPais" size="1" tabindex="10" onChange="submit();">
    '<option selected>-- Seleccione un País --
    '<%Call ComboRS(Pais)%>

    This is the code for the recorset of the other combo:

    strCentral = "select IdProyecto, NmProyecto from Proyectos Where IdPais
    ='"& CadenaPais &"' AND Tecnologia = '"& TipoPlanta &"' order by NmProyecto"
    Call OpenRS(rsCentral,strCentral,ConnAxs)
    Central = rsCentral.GetRows
    Call CloseRS(rsCentral)

    I do not get any error message. My problem is tha once I select the first
    combo it did filter the second one, but I can't see the data I just selected.
    Let's say I select Colombia, and I see it at this pont. But very soon
    Colombia is not there, anymore.

    Thanks a lot!!!


    "Ray Costanzo [MVP]" wrote:

    > Show the code you're using to populate the first drop down and the code
    > you're using to retrieve that value.
    >
    > Ray at work
    >
    > "Lina Manjarres" <> wrote in message
    > news:...
    > > Hello,
    > >
    > > I have a form page in ASP where the first menu/list function as a filter

    > of
    > > the second menu list. Once I select an item form the first combo I get the
    > > second menu full of options. This is correct. My probem is that the first
    > > combo gets the default value again and I do not see what I did choose.
    > >
    > > I do not know if I explained this correctly. Hope someone can understand

    > me.
    > >
    > > Thanks a lot, Lina

    >
    >
    >
    Lina Manjarres, Jul 20, 2005
    #3
  4. Try this:

    sSelectedCategory = Request.Form("cboPais")

    Then get rid of the "selected" text in that dropdown box. (<option
    selected>-- Seleccione un País --)

    Then, add a second argument to your ComboRS function and use it as such:

    Function ComboRS(vector,SelectedValue)
    'Pinto el combo
    for i= 0 to UBound(vector, 2)
    Response.Write "<option value='" & vector(0,i) & " - " &
    vector(1,i)& "'"
    If vector(0,i) = SelectedValue Then REsponse.Write " selected"
    Response.Write ">" & vector(0,i) & " - " & vector(1,i) & vbCrLf
    next
    End Function


    Ray at work

    "Lina Manjarres" <> wrote in message
    news:D...
    > This is the function code tu fill the combos, wher vector is a variable

    Pais
    > filled with a recorset.
    >
    > Function ComboRS(vector)
    > 'Pinto el combo
    > for i= 0 to UBound(vector, 2)
    > Response.Write "<option value='"& vector(0,i) &" - "& vector(1,i)&"'>"&
    > vector(0,i) &" - "& vector(1,i) & vbCrLf
    > next
    > End Function
    >
    >
    > %>
    >
    >
    > Here is the call to the recordset and the way I fill the variable Pais:
    >
    > strPais = "select IdPais, NmPais from Paises order by NmPais"
    > Call OpenRS(rsPais,strPais,ConnAxs)
    > Pais = rsPais.GetRows
    > Call CloseRS(rsPais)
    >
    > If request.form("CboPais") = "" Then
    > CadenaPais = "57"
    > Else
    > Izquierda = instr(1,request.form("CboPais"),"-")
    > CadenaPAis = Trim(Left(request.form("CboPais"),Izquierda - 1))
    > End If
    >
    > Here is how I work out the first combo:
    >
    > '<select name="cboPais" size="1" tabindex="10" onChange="submit();">
    > '<option selected>-- Seleccione un País --
    > '<%Call ComboRS(Pais)%>
    >
    > This is the code for the recorset of the other combo:
    >
    > strCentral = "select IdProyecto, NmProyecto from Proyectos Where IdPais
    > ='"& CadenaPais &"' AND Tecnologia = '"& TipoPlanta &"' order by

    NmProyecto"
    > Call OpenRS(rsCentral,strCentral,ConnAxs)
    > Central = rsCentral.GetRows
    > Call CloseRS(rsCentral)
    >
    > I do not get any error message. My problem is tha once I select the first
    > combo it did filter the second one, but I can't see the data I just

    selected.
    > Let's say I select Colombia, and I see it at this pont. But very soon
    > Colombia is not there, anymore.
    >
    > Thanks a lot!!!
    >
    >
    > "Ray Costanzo [MVP]" wrote:
    >
    > > Show the code you're using to populate the first drop down and the code
    > > you're using to retrieve that value.
    > >
    > > Ray at work
    > >
    > > "Lina Manjarres" <> wrote in

    message
    > > news:...
    > > > Hello,
    > > >
    > > > I have a form page in ASP where the first menu/list function as a

    filter
    > > of
    > > > the second menu list. Once I select an item form the first combo I get

    the
    > > > second menu full of options. This is correct. My probem is that the

    first
    > > > combo gets the default value again and I do not see what I did choose.
    > > >
    > > > I do not know if I explained this correctly. Hope someone can

    understand
    > > me.
    > > >
    > > > Thanks a lot, Lina

    > >
    > >
    > >
    Ray Costanzo [MVP], Jul 20, 2005
    #4
  5. Thank you Ray

    I follow your instruccions, but I allways get the first combo to display the
    first item in the table instead the one I selected.

    Do you think I am doing something wrong?

    You can see what I am saying by going to this link:
    http://manager-soft.com/clientes/microcad/html/inicio.htm
    and then try the menu "Plantas de Generación" and then "Líneas"

    Thanks a lot!

    "Ray Costanzo [MVP]" wrote:

    > Try this:
    >
    > sSelectedCategory = Request.Form("cboPais")
    >
    > Then get rid of the "selected" text in that dropdown box. (<option
    > selected>-- Seleccione un País --)
    >
    > Then, add a second argument to your ComboRS function and use it as such:
    >
    > Function ComboRS(vector,SelectedValue)
    > 'Pinto el combo
    > for i= 0 to UBound(vector, 2)
    > Response.Write "<option value='" & vector(0,i) & " - " &
    > vector(1,i)& "'"
    > If vector(0,i) = SelectedValue Then REsponse.Write " selected"
    > Response.Write ">" & vector(0,i) & " - " & vector(1,i) & vbCrLf
    > next
    > End Function
    >
    >
    > Ray at work
    >
    > "Lina Manjarres" <> wrote in message
    > news:D...
    > > This is the function code tu fill the combos, wher vector is a variable

    > Pais
    > > filled with a recorset.
    > >
    > > Function ComboRS(vector)
    > > 'Pinto el combo
    > > for i= 0 to UBound(vector, 2)
    > > Response.Write "<option value='"& vector(0,i) &" - "& vector(1,i)&"'>"&
    > > vector(0,i) &" - "& vector(1,i) & vbCrLf
    > > next
    > > End Function
    > >
    > >
    > > %>
    > >
    > >
    > > Here is the call to the recordset and the way I fill the variable Pais:
    > >
    > > strPais = "select IdPais, NmPais from Paises order by NmPais"
    > > Call OpenRS(rsPais,strPais,ConnAxs)
    > > Pais = rsPais.GetRows
    > > Call CloseRS(rsPais)
    > >
    > > If request.form("CboPais") = "" Then
    > > CadenaPais = "57"
    > > Else
    > > Izquierda = instr(1,request.form("CboPais"),"-")
    > > CadenaPAis = Trim(Left(request.form("CboPais"),Izquierda - 1))
    > > End If
    > >
    > > Here is how I work out the first combo:
    > >
    > > '<select name="cboPais" size="1" tabindex="10" onChange="submit();">
    > > '<option selected>-- Seleccione un País --
    > > '<%Call ComboRS(Pais)%>
    > >
    > > This is the code for the recorset of the other combo:
    > >
    > > strCentral = "select IdProyecto, NmProyecto from Proyectos Where IdPais
    > > ='"& CadenaPais &"' AND Tecnologia = '"& TipoPlanta &"' order by

    > NmProyecto"
    > > Call OpenRS(rsCentral,strCentral,ConnAxs)
    > > Central = rsCentral.GetRows
    > > Call CloseRS(rsCentral)
    > >
    > > I do not get any error message. My problem is tha once I select the first
    > > combo it did filter the second one, but I can't see the data I just

    > selected.
    > > Let's say I select Colombia, and I see it at this pont. But very soon
    > > Colombia is not there, anymore.
    > >
    > > Thanks a lot!!!
    > >
    > >
    > > "Ray Costanzo [MVP]" wrote:
    > >
    > > > Show the code you're using to populate the first drop down and the code
    > > > you're using to retrieve that value.
    > > >
    > > > Ray at work
    > > >
    > > > "Lina Manjarres" <> wrote in

    > message
    > > > news:...
    > > > > Hello,
    > > > >
    > > > > I have a form page in ASP where the first menu/list function as a

    > filter
    > > > of
    > > > > the second menu list. Once I select an item form the first combo I get

    > the
    > > > > second menu full of options. This is correct. My probem is that the

    > first
    > > > > combo gets the default value again and I do not see what I did choose.
    > > > >
    > > > > I do not know if I explained this correctly. Hope someone can

    > understand
    > > > me.
    > > > >
    > > > > Thanks a lot, Lina
    > > >
    > > >
    > > >

    >
    >
    >
    Lina Manjarres, Jul 20, 2005
    #5
  6. Well, the most important thing is to understand what the goal is. The goal
    is to take have the server be aware of the value of the selected item when
    it redraws the page after the user selects an item from the first dropdown.
    Then, as it loops through those items and is writing out all the <option>
    html again, what you want to do in your loop is put in a test to see if the
    item that is currently being written is the one that the person selected.
    If it is, then add " selected" to the HTML output. Here's a simple example:

    <%
    Dim i
    i = Request.Querystring("dropdown")
    %>
    <html>
    <body>
    <form method="get">
    <select name="dropdown" onchange="this.form.submit();">
    <%
    For j = 1 To 10
    Response.Write "<option value=""" & j & """"
    If CStr(j) = CStr(i) Then Response.Write " selected"
    Response.Write ">" & j & "</option>" & vbCrLf
    Next
    %>
    </form>
    </body>
    </html>

    As far as your page, I don't see any dropdowns. I just see javascript
    errors and EOF errors.

    Ray at home




    "Lina Manjarres" <> wrote in message
    news:D...
    > Thank you Ray
    >
    > I follow your instruccions, but I allways get the first combo to display
    > the
    > first item in the table instead the one I selected.
    >
    > Do you think I am doing something wrong?
    >
    > You can see what I am saying by going to this link:
    > http://manager-soft.com/clientes/microcad/html/inicio.htm
    > and then try the menu "Plantas de Generación" and then "Líneas"
    >
    > Thanks a lot!
    >
    Ray Costanzo [MVP], Jul 21, 2005
    #6
  7. Yes, something like that is what i am looking for.
    The link I gave you is working. Just make sure you select "Plantas de
    Generación" and then "Líneas"

    So, Ray, what should I do? Should I change my forms from Post to GET?


    "Ray Costanzo [MVP]" wrote:

    > Well, the most important thing is to understand what the goal is. The goal
    > is to take have the server be aware of the value of the selected item when
    > it redraws the page after the user selects an item from the first dropdown.
    > Then, as it loops through those items and is writing out all the <option>
    > html again, what you want to do in your loop is put in a test to see if the
    > item that is currently being written is the one that the person selected.
    > If it is, then add " selected" to the HTML output. Here's a simple example:
    >
    > <%
    > Dim i
    > i = Request.Querystring("dropdown")
    > %>
    > <html>
    > <body>
    > <form method="get">
    > <select name="dropdown" onchange="this.form.submit();">
    > <%
    > For j = 1 To 10
    > Response.Write "<option value=""" & j & """"
    > If CStr(j) = CStr(i) Then Response.Write " selected"
    > Response.Write ">" & j & "</option>" & vbCrLf
    > Next
    > %>
    > </form>
    > </body>
    > </html>
    >
    > As far as your page, I don't see any dropdowns. I just see javascript
    > errors and EOF errors.
    >
    > Ray at home
    >
    >
    >
    >
    > "Lina Manjarres" <> wrote in message
    > news:D...
    > > Thank you Ray
    > >
    > > I follow your instruccions, but I allways get the first combo to display
    > > the
    > > first item in the table instead the one I selected.
    > >
    > > Do you think I am doing something wrong?
    > >
    > > You can see what I am saying by going to this link:
    > > http://manager-soft.com/clientes/microcad/html/inicio.htm
    > > and then try the menu "Plantas de Generación" and then "Líneas"
    > >
    > > Thanks a lot!
    > >

    >
    >
    Lina Manjarres, Jul 21, 2005
    #7
  8. "Lina Manjarres" <> wrote in message
    news:...
    > Yes, something like that is what i am looking for.


    Have you tried applying the logic to your specific code?


    > The link I gave you is working. Just make sure you select "Plantas de
    > Generación" and then "Líneas"


    CollapseMenu is not defined - Line 62
    collapse is not defined - Line 86
    collapse is not defined - Line 196
    collapse is not defined - Line 53
    collapse is not defined - Line 1

    That's what I get in Firefox.



    > So, Ray, what should I do? Should I change my forms from Post to GET?


    Not necessarily. If there's reason to post, post. Then just use
    Request.Form instead of Request.QueryString

    Ray at work
    Ray Costanzo [MVP], Jul 21, 2005
    #8
  9. I have tried what you told me but I do not get anything better.
    Maybe I do not do what I am supposed to do.

    Try the link again and see if it works now.

    Thanks a lot!

    "Ray Costanzo [MVP]" wrote:

    >
    > "Lina Manjarres" <> wrote in message
    > news:...
    > > Yes, something like that is what i am looking for.

    >
    > Have you tried applying the logic to your specific code?
    >
    >
    > > The link I gave you is working. Just make sure you select "Plantas de
    > > Generación" and then "Líneas"

    >
    > CollapseMenu is not defined - Line 62
    > collapse is not defined - Line 86
    > collapse is not defined - Line 196
    > collapse is not defined - Line 53
    > collapse is not defined - Line 1
    >
    > That's what I get in Firefox.
    >
    >
    >
    > > So, Ray, what should I do? Should I change my forms from Post to GET?

    >
    > Not necessarily. If there's reason to post, post. Then just use
    > Request.Form instead of Request.QueryString
    >
    > Ray at work
    >
    >
    >
    Lina Manjarres, Jul 22, 2005
    #9
    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. Miguel Dias Moura
    Replies:
    3
    Views:
    4,297
    Bruno Sirianni
    Apr 3, 2004
  2. Vilmar
    Replies:
    0
    Views:
    463
    Vilmar
    May 27, 2004
  3. itzikkl
    Replies:
    0
    Views:
    5,766
    itzikkl
    Mar 27, 2005
  4. mike
    Replies:
    2
    Views:
    600
  5. Karl-Inge Reknes

    Menu question (list menu)

    Karl-Inge Reknes, Dec 22, 2006, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    155
    Karl-Inge Reknes
    Dec 22, 2006
Loading...

Share This Page