Assign vars from a for loop

Discussion in 'ASP General' started by Dave Karmens, Feb 27, 2004.

  1. Dave Karmens

    Dave Karmens Guest

    for each inputField in Request.Form
    for each inputValue in Request.Form(inputField)
    response.write inputField & " = " & inputValue & "<br>"
    next
    next

    Let's say this returns:

    fld = fish
    fld = dog
    fld = cat
    fld = bird
    fld = emu

    How can I get those values into a variables that I can then put into a
    SQL string?

    insert into tbl_tmp
    (critter1, critter2, critter3, critter4, critter5)
    values
    (?????)
    Dave Karmens, Feb 27, 2004
    #1
    1. Advertising

  2. Dave Karmens wrote:
    > for each inputField in Request.Form
    > for each inputValue in Request.Form(inputField)
    > response.write inputField & " = " & inputValue & "<br>"
    > next
    > next
    >
    > Let's say this returns:
    >
    > fld = fish
    > fld = dog
    > fld = cat
    > fld = bird
    > fld = emu
    >
    > How can I get those values into a variables that I can then put into a
    > SQL string?
    >
    > insert into tbl_tmp
    > (critter1, critter2, critter3, critter4, critter5)
    > values
    > (?????)


    I think you can simply do this:

    Response.Write Request.form("fld")

    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.
    Bob Barrows [MVP], Feb 27, 2004
    #2
    1. Advertising

  3. Dave Karmens

    Dave Karmens Guest

    For each of the values? Won't that just return the same thing each time?

    Bob Barrows [MVP] wrote:

    > Dave Karmens wrote:
    >
    >>for each inputField in Request.Form
    >>for each inputValue in Request.Form(inputField)
    >>response.write inputField & " = " & inputValue & "<br>"
    >>next
    >>next
    >>
    >>Let's say this returns:
    >>
    >>fld = fish
    >>fld = dog
    >>fld = cat
    >>fld = bird
    >>fld = emu
    >>
    >>How can I get those values into a variables that I can then put into a
    >>SQL string?
    >>
    >>insert into tbl_tmp
    >>(critter1, critter2, critter3, critter4, critter5)
    >>values
    >>(?????)

    >
    >
    > I think you can simply do this:
    >
    > Response.Write Request.form("fld")
    >
    Dave Karmens, Feb 27, 2004
    #3
  4. Dave Karmens

    Dave Karmens Guest

    Basically, I want to get all the flds into:

    values( )

    Bob Barrows [MVP] wrote:

    > Dave Karmens wrote:
    >
    >>for each inputField in Request.Form
    >>for each inputValue in Request.Form(inputField)
    >>response.write inputField & " = " & inputValue & "<br>"
    >>next
    >>next
    >>
    >>Let's say this returns:
    >>
    >>fld = fish
    >>fld = dog
    >>fld = cat
    >>fld = bird
    >>fld = emu
    >>
    >>How can I get those values into a variables that I can then put into a
    >>SQL string?
    >>
    >>insert into tbl_tmp
    >>(critter1, critter2, critter3, critter4, critter5)
    >>values
    >>(?????)

    >
    >
    > I think you can simply do this:
    >
    > Response.Write Request.form("fld")
    >
    Dave Karmens, Feb 27, 2004
    #4
  5. Dave Karmens wrote:
    > For each of the values? Won't that just return the same thing each
    > time?
    >

    Try it!! It would have taken you 10 seconds to try my suggestion. Instead,
    you posted two replies and wasted several minutes of your time ...

    The variable will return a comma-delimited list of the values.

    Bob Barrows
    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.
    Bob Barrows [MVP], Feb 27, 2004
    #5
  6. Dave Karmens

    Ray at Guest

    See your other post on this topic.

    Ray at work

    "Dave Karmens" <> wrote in message
    news:uXbSkqU$...
    > For each of the values? Won't that just return the same thing each time?
    >
    > Bob Barrows [MVP] wrote:
    >
    > > Dave Karmens wrote:
    > >
    > >>for each inputField in Request.Form
    > >>for each inputValue in Request.Form(inputField)
    > >>response.write inputField & " = " & inputValue & "<br>"
    > >>next
    > >>next
    > >>
    > >>Let's say this returns:
    > >>
    > >>fld = fish
    > >>fld = dog
    > >>fld = cat
    > >>fld = bird
    > >>fld = emu
    > >>
    > >>How can I get those values into a variables that I can then put into a
    > >>SQL string?
    > >>
    > >>insert into tbl_tmp
    > >>(critter1, critter2, critter3, critter4, critter5)
    > >>values
    > >>(?????)

    > >
    > >
    > > I think you can simply do this:
    > >
    > > Response.Write Request.form("fld")
    > >
    Ray at, Feb 27, 2004
    #6
  7. Dave Karmens

    Dave Karmens Guest

    Thanks Bob, that worked.

    Bob Barrows [MVP] wrote:

    > Dave Karmens wrote:
    >
    >>For each of the values? Won't that just return the same thing each
    >>time?
    >>

    >
    > Try it!! It would have taken you 10 seconds to try my suggestion. Instead,
    > you posted two replies and wasted several minutes of your time ...
    >
    > The variable will return a comma-delimited list of the values.
    >
    > Bob Barrows
    Dave Karmens, Feb 27, 2004
    #7
    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. sku11monkey

    Using loop vars in a testbench

    sku11monkey, Feb 16, 2004, in forum: VHDL
    Replies:
    2
    Views:
    656
    Grigorios Angelis
    Feb 18, 2004
  2. Jon

    app vars and cache vars

    Jon, Dec 14, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    391
  3. Linuxguy123
    Replies:
    7
    Views:
    683
    Paddy O'Loughlin
    Feb 20, 2009
  4. caccolangrifata
    Replies:
    18
    Views:
    392
    Chris Torek
    Jul 22, 2011
  5. Isaac Won
    Replies:
    9
    Views:
    364
    Ulrich Eckhardt
    Mar 4, 2013
Loading...

Share This Page