Assign vars from a for loop

D

Dave Karmens

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
(?????)
 
B

Bob Barrows [MVP]

Dave said:
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")
 
B

Bob Barrows [MVP]

Dave said:
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
 
D

Dave Karmens

Thanks Bob, that worked.
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top