|
 |
access_asp thread: Access form field names/ids
Message #1 by "Hamsa" <hamsa_@h...> on Wed, 21 Aug 2002 17:07:12
|
|
Hi
How do I fetch the name of form fields in an asp page?
I have a form with a few input fields. When I submit the form, how do I
fetch the name or Id of these input fields?
thanks in advance
Hamsa
Message #2 by "Rob Parkhouse" <rparkhouse@o...> on Thu, 22 Aug 2002 00:51:21
|
|
> Hi
> How do I fetch the name of form fields in an asp page?
> I have a form with a few input fields. When I submit the form, how do I
f> etch the name or Id of these input fields?
> thanks in advance
H> amsa
Generally you would already know the form field names because you
programmed the ASP. You get the VALUES using syntax like
val = Request.Form("fldname") - where fldname is hardcoded.
If you have generated field names you could get the name and value by
something like:
Dim fld
Dim fldVal
Dim fldName
For Each fld in Request.Form
fldVal = Request.Form(fld).Value
fldName = Request.Form(fld).Name
Next
Hope this helps
Message #3 by "Raymond Dalton" <rdalton@c...> on Fri, 23 Aug 2002 10:26:26 -0500
|
|
In response to:
> > How do I fetch the name of form fields in an asp page?
This code will allow you to assign any form field to a variable of the same
name, i.e. request.form("thisfield") becomes a variable called thisfield
that holds the value of request.form("thisfield"). This code saves a lot of
time in hard coding form variables, but it does not work with input types
that are images. If you are using an image as an input type, such as for
your submit button let me know, and I will give you a work around. Thanks,
Raymond
'set variables for form submission
For Each Field In Request.Form
TheString = Field & " = Request.Form(""" & Field & """)"
Execute(TheString)
Next
'add this code if you also want to capture querystrings the same way
For Each Field In Request.QueryString
TheString = Field & " = Request.QueryString(""" & Field & """)"
Execute(TheString)
Next
|
|
 |