Can you use dynamic data in a request form

B

bateman

Hi, I am am trying to write some code to perform a INSERT in SQL table using
a loop. What would be great is a way of dynamically entering in data in a
requaest.form
ie the final code should look something like:


if Request.Form("type1") = "1" then


where the 1 in "type1" is dynamic so the code would look something like


Request.Form("type" & Rs.("fld_type_id") & ") = "1" then

But not sure how to form this or whether it would work, anyone have any
idea?
 
B

Bob Barrows

bateman said:
Hi, I am am trying to write some code to perform a INSERT in SQL
table using a loop. What would be great is a way of dynamically
entering in data in a requaest.form
ie the final code should look something like:


if Request.Form("type1") = "1" then


where the 1 in "type1" is dynamic so the code would look something
like


Request.Form("type" & Rs.("fld_type_id") & ") = "1" then

But not sure how to form this or whether it would work, anyone have
any idea?

Of course it would work. All you need inside the parntheses is a string
containing the name of the variable. How that string is built is irrelevant.

sVar = "type" & Rs.("fld_type_id")
if Request.Form(sVar) = "1" then

Or, if you want to fly by the seat of your pants:
if Request.Form("type" & Rs.("fld_type_id") ) = "1" then

HTH,
Bob Barrows
 
B

bateman

Bob Barrows said:
Of course it would work. All you need inside the parntheses is a string
containing the name of the variable. How that string is built is irrelevant.

sVar = "type" & Rs.("fld_type_id")
if Request.Form(sVar) = "1" then

Or, if you want to fly by the seat of your pants:
if Request.Form("type" & Rs.("fld_type_id") ) = "1" then

Million Thanks, works perfectly
 

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
474,145
Messages
2,570,826
Members
47,371
Latest member
Brkaa

Latest Threads

Top