Dinamic menu form selection - please help

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default Dinamic menu form selection - please help

    Hi all,
    my problem is the same:

    I populate a selection menu in a form with values from an access db and
    tht's OK in the sense that my selection works fine.

    The problem is that I don't know how to set another field of the form
    with a value depending on my first selection.

    I mean, with the first menu selection I get from a db id and name, then
    I display the menu with all the names.
    How can I, if a name is selected, set a variable with the id associated
    to that name and insert it in a hidden field of the form?

    Below my code for the menu... I tried some things without success.

    THX in advance
    PGei

    <td><font face="Arial"><% x_idgara = 0 'set default value %><%
    x_idgaraList = "<SELECT name='x_idgara'><OPTION value=''>Please
    Select</OPTION>"
    sqlwrk = "SELECT [id], [name] FROM [tbl_games]"
    Set rswrk = Server.CreateObject("ADODB.Recordset")
    rswrk.Open sqlwrk, conn, 1, 2
    If Not rswrk.EOF Then
    datawrk = rswrk.GetRows
    rowswrk = UBound(datawrk, 2)
    For rowcntwrk = 0 To rowswrk
    x_idgaraList = x_idgaraList & "<OPTION value='" & datawrk(0,
    rowcntwrk) & "'"
    If datawrk(0, rowcntwrk) = x_idgara Then
    x_idgaraList = x_idgaraList & " selected"
    End If
    x_idgaraList = x_idgaraList & ">" & datawrk(1, rowcntwrk) &
    "</option>"
    Next
    End If
    rswrk.Close
    Set rswrk = Nothing
    x_idgaraList = x_idgaraList & "</SELECT>"
    response.write x_idgaraList
    %></font>&nbsp;</td>


    PiGei Guest

  2. Similar Questions and Discussions

    1. Placing a variable containing a Menu selection inside aspecific Cell of a datagrid
      i have a function that gets the menu selection and then places the cursor into the specific field i want to insert the record into; and once in the...
    2. How do I put a Menu selection into a specific cell of adatagrid...
      i have a function that gets the menu selection and then places the cursor into the specific field i want to insert the record into; and once in the...
    3. Taking Action on Dynamic Menu Selection
      :embarrassment; How do i get an action to take place when a menu item is selected from a dynamic menu? I want to move to a specific record item in...
    4. Making a selection in List Menu
      Hey all, I have a multiple list item that I am passing a variable in to have one of the items selected. What I would like to know is it possible to...
    5. CS: Font selection menu TOO WIDE! (?!?!)
      Hi - I'm having a little low-level annoyance with my font menu - when I choose the pull-down menu from the pallette, the list is about 80% the...
  3. #2

    Default Re: Dinamic menu form selection - please help

    On Tue, 10 Feb 2004 13:09:22 +0100, "PiGei"
    <james_milanNOSPAM@hotmail.com> wrote:
    >Hi all,
    >my problem is the same:
    >
    >I populate a selection menu in a form with values from an access db and
    >tht's OK in the sense that my selection works fine.
    >
    >The problem is that I don't know how to set another field of the form
    >with a value depending on my first selection.
    FAQ:

    How do I make one dropdown depend on another?
    [url]http://www.aspfaq.com/show.asp?id=2270[/url]

    Jeff

    >I mean, with the first menu selection I get from a db id and name, then
    >I display the menu with all the names.
    >How can I, if a name is selected, set a variable with the id associated
    >to that name and insert it in a hidden field of the form?
    >
    >Below my code for the menu... I tried some things without success.
    >
    >THX in advance
    >PGei
    >
    ><td><font face="Arial"><% x_idgara = 0 'set default value %><%
    >x_idgaraList = "<SELECT name='x_idgara'><OPTION value=''>Please
    >Select</OPTION>"
    >sqlwrk = "SELECT [id], [name] FROM [tbl_games]"
    >Set rswrk = Server.CreateObject("ADODB.Recordset")
    >rswrk.Open sqlwrk, conn, 1, 2
    >If Not rswrk.EOF Then
    > datawrk = rswrk.GetRows
    > rowswrk = UBound(datawrk, 2)
    > For rowcntwrk = 0 To rowswrk
    > x_idgaraList = x_idgaraList & "<OPTION value='" & datawrk(0,
    >rowcntwrk) & "'"
    > If datawrk(0, rowcntwrk) = x_idgara Then
    > x_idgaraList = x_idgaraList & " selected"
    > End If
    > x_idgaraList = x_idgaraList & ">" & datawrk(1, rowcntwrk) &
    >"</option>"
    > Next
    >End If
    >rswrk.Close
    >Set rswrk = Nothing
    >x_idgaraList = x_idgaraList & "</SELECT>"
    >response.write x_idgaraList
    >%></font>&nbsp;</td>
    >
    Jeff Cochran Guest

  4. #3

    Default Re: Dinamic menu form selection - please help

    Thanks but I can't find my solution in it.
    What I don't understand is "I selected an item then how can I put the
    relative id - I got the two with the call to the db - in my variable?

    I don't understand the javascript in that examples...

    Any tips?

    thanks
    PGei

    "Jeff Cochran" <jcochran.nospam@naplesgov.com> wrote in message
    news:4029d7c8.607438961@msnews.microsoft.com...
    > On Tue, 10 Feb 2004 13:09:22 +0100, "PiGei"
    > <james_milanNOSPAM@hotmail.com> wrote:
    >
    > >Hi all,
    > >my problem is the same:
    > >
    > >I populate a selection menu in a form with values from an access db
    and
    > >tht's OK in the sense that my selection works fine.
    > >
    > >The problem is that I don't know how to set another field of the form
    > >with a value depending on my first selection.
    >
    > FAQ:
    >
    > How do I make one dropdown depend on another?
    > [url]http://www.aspfaq.com/show.asp?id=2270[/url]
    >
    > Jeff
    >
    >
    > >I mean, with the first menu selection I get from a db id and name,
    then
    > >I display the menu with all the names.
    > >How can I, if a name is selected, set a variable with the id
    associated
    > >to that name and insert it in a hidden field of the form?
    > >
    > >Below my code for the menu... I tried some things without success.
    > >
    > >THX in advance
    > >PGei
    > >
    > ><td><font face="Arial"><% x_idgara = 0 'set default value %><%
    > >x_idgaraList = "<SELECT name='x_idgara'><OPTION value=''>Please
    > >Select</OPTION>"
    > >sqlwrk = "SELECT [id], [name] FROM [tbl_games]"
    > >Set rswrk = Server.CreateObject("ADODB.Recordset")
    > >rswrk.Open sqlwrk, conn, 1, 2
    > >If Not rswrk.EOF Then
    > > datawrk = rswrk.GetRows
    > > rowswrk = UBound(datawrk, 2)
    > > For rowcntwrk = 0 To rowswrk
    > > x_idgaraList = x_idgaraList & "<OPTION value='" & datawrk(0,
    > >rowcntwrk) & "'"
    > > If datawrk(0, rowcntwrk) = x_idgara Then
    > > x_idgaraList = x_idgaraList & " selected"
    > > End If
    > > x_idgaraList = x_idgaraList & ">" & datawrk(1, rowcntwrk) &
    > >"</option>"
    > > Next
    > >End If
    > >rswrk.Close
    > >Set rswrk = Nothing
    > >x_idgaraList = x_idgaraList & "</SELECT>"
    > >response.write x_idgaraList
    > >%></font>&nbsp;</td>
    > >
    >

    PiGei Guest

  5. #4

    Default Re: Dinamic menu form selection - please help

    On Tue, 10 Feb 2004 15:28:42 +0100, "PiGei"
    <james_milanNOSPAM@hotmail.com> wrote:
    >Thanks but I can't find my solution in it.
    >What I don't understand is "I selected an item then how can I put the
    >relative id - I got the two with the call to the db - in my variable?
    There are two approaches to this, client side and server side. Client
    side requires no extra trips to the server, but pulls more data
    across. Server side, each time a drop-down list item is selected, a
    query to the server returns the next set of possibilities. The
    examples list client-side options, since that's normally the best for
    performance and other reasons.
    >I don't understand the javascript in that examples...
    Can't help you much there, but a Javascript newsgroup would likely be
    able to. The Javascript is pretty straightforward, but you do need at
    least a base working knowledge to understand what to change.

    Jeff

    >"Jeff Cochran" <jcochran.nospam@naplesgov.com> wrote in message
    >news:4029d7c8.607438961@msnews.microsoft.com...
    >> On Tue, 10 Feb 2004 13:09:22 +0100, "PiGei"
    >> <james_milanNOSPAM@hotmail.com> wrote:
    >>
    >> >Hi all,
    >> >my problem is the same:
    >> >
    >> >I populate a selection menu in a form with values from an access db
    >and
    >> >tht's OK in the sense that my selection works fine.
    >> >
    >> >The problem is that I don't know how to set another field of the form
    >> >with a value depending on my first selection.
    >>
    >> FAQ:
    >>
    >> How do I make one dropdown depend on another?
    >> [url]http://www.aspfaq.com/show.asp?id=2270[/url]
    >>
    >> Jeff
    >>
    >>
    >> >I mean, with the first menu selection I get from a db id and name,
    >then
    >> >I display the menu with all the names.
    >> >How can I, if a name is selected, set a variable with the id
    >associated
    >> >to that name and insert it in a hidden field of the form?
    >> >
    >> >Below my code for the menu... I tried some things without success.
    >> >
    >> >THX in advance
    >> >PGei
    >> >
    >> ><td><font face="Arial"><% x_idgara = 0 'set default value %><%
    >> >x_idgaraList = "<SELECT name='x_idgara'><OPTION value=''>Please
    >> >Select</OPTION>"
    >> >sqlwrk = "SELECT [id], [name] FROM [tbl_games]"
    >> >Set rswrk = Server.CreateObject("ADODB.Recordset")
    >> >rswrk.Open sqlwrk, conn, 1, 2
    >> >If Not rswrk.EOF Then
    >> > datawrk = rswrk.GetRows
    >> > rowswrk = UBound(datawrk, 2)
    >> > For rowcntwrk = 0 To rowswrk
    >> > x_idgaraList = x_idgaraList & "<OPTION value='" & datawrk(0,
    >> >rowcntwrk) & "'"
    >> > If datawrk(0, rowcntwrk) = x_idgara Then
    >> > x_idgaraList = x_idgaraList & " selected"
    >> > End If
    >> > x_idgaraList = x_idgaraList & ">" & datawrk(1, rowcntwrk) &
    >> >"</option>"
    >> > Next
    >> >End If
    >> >rswrk.Close
    >> >Set rswrk = Nothing
    >> >x_idgaraList = x_idgaraList & "</SELECT>"
    >> >response.write x_idgaraList
    >> >%></font>&nbsp;</td>
    >> >
    >>
    >
    Jeff Cochran Guest

  6. #5

    Default Re: Dinamic menu form selection - please help

    Check out
    [url]http://www.greggriffiths.org/webdev/clientside/javascript/linkeddropdowns/[/url]
    for some client side that will do this for you, at present it simply
    populates another dropdown list, but if you wnat it to populate a textbox
    or similar you should be able to amend the code.

    PiGei wrote:
    > Hi all,
    > my problem is the same:
    >
    > I populate a selection menu in a form with values from an access db and
    > tht's OK in the sense that my selection works fine.
    >
    > The problem is that I don't know how to set another field of the form
    > with a value depending on my first selection.
    >
    > I mean, with the first menu selection I get from a db id and name, then
    > I display the menu with all the names.
    > How can I, if a name is selected, set a variable with the id associated
    > to that name and insert it in a hidden field of the form?
    >
    > Below my code for the menu... I tried some things without success.
    >
    > THX in advance
    > PGei
    >
    > <td><font face="Arial"><% x_idgara = 0 'set default value %><%
    > x_idgaraList = "<SELECT name='x_idgara'><OPTION value=''>Please
    > Select</OPTION>"
    > sqlwrk = "SELECT [id], [name] FROM [tbl_games]"
    > Set rswrk = Server.CreateObject("ADODB.Recordset")
    > rswrk.Open sqlwrk, conn, 1, 2
    > If Not rswrk.EOF Then
    > datawrk = rswrk.GetRows
    > rowswrk = UBound(datawrk, 2)
    > For rowcntwrk = 0 To rowswrk
    > x_idgaraList = x_idgaraList & "<OPTION value='" & datawrk(0,
    > rowcntwrk) & "'"
    > If datawrk(0, rowcntwrk) = x_idgara Then
    > x_idgaraList = x_idgaraList & " selected"
    > End If
    > x_idgaraList = x_idgaraList & ">" & datawrk(1, rowcntwrk) &
    > "</option>"
    > Next
    > End If
    > rswrk.Close
    > Set rswrk = Nothing
    > x_idgaraList = x_idgaraList & "</SELECT>"
    > response.write x_idgaraList
    > %></font>&nbsp;</td>
    Greg Griffiths Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139