Objects and collections

R

Roland Hall

I have two questions which I am unable to find answers to:

1. What is the difference between Request.Form and Request.Item?

I can do this:

dim obj, postback, o
postback = Request.Form("postback")
if postback <> "" then
for each obj in Request.Form
o = Request.Item(obj)
if o <> "postback" then
session(obj) = o
end if
Response.Write session(obj) & "<br />" & vbCrLf
next
end if

What makes Request.Item different in this respect than Request.Form? Is
there a benefit one way or the other?

2. Is it possible to use FOR...EACH, with a form and make the variable an
object?

Ex.

If I use:
for each obj in Request.Form

obj is not an object as I cannot then write:

Response.Write obj.value to get the value of the form variable.

If my form was:

<input type="text" name="iname" value="" />

and I typed in Roland and submitted, I cannot with the FOR...EACH use
obj.value to get the value. Is there a way to do it that I am not aware of?

TIA...

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
 
B

Bob Barrows [MVP]

Roland said:
I have two questions which I am unable to find answers to:

1. What is the difference between Request.Form and Request.Item?

Request.Item(something) is the same as Request(something). Basically, Item
is the default property, and you've requested the first itme in all the
Request object's collections whose key matches your specification
What makes Request.Item different in this respect than Request.Form?
Is there a benefit one way or the other?

I'm sure you've read all our admonitions in the past about failing to
specify the collection whose item you wish to retrieve...
2. Is it possible to use FOR...EACH, with a form and make the
variable an object?

for each key in Request.Form
Response.Write key & ": " & Response.Form(key)
next

Bob Barrows
 
R

Roland Hall

in message
: Roland Hall wrote:
: > I have two questions which I am unable to find answers to:
: >
: > 1. What is the difference between Request.Form and Request.Item?
:
: Request.Item(something) is the same as Request(something). Basically, Item
: is the default property, and you've requested the first itme in all the
: Request object's collections whose key matches your specification
:
: > What makes Request.Item different in this respect than Request.Form?
: > Is there a benefit one way or the other?
:
: I'm sure you've read all our admonitions in the past about failing to
: specify the collection whose item you wish to retrieve...
:
: >
: > 2. Is it possible to use FOR...EACH, with a form and make the
: > variable an object?
:
: for each key in Request.Form
: Response.Write key & ": " & Response.Form(key)
: next

key is the form element
Response.Form(key) would return the value but how can I make key an object
and use key.value to get the value?

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
 
B

Bob Barrows [MVP]

Roland said:
key is the form element

Actually, it is the key of the form element
Response.Form(key) would return the value but how can I make key an
object and use key.value to get the value?

Unfortunately, the vbscript enumerator does not work that way with these
collections. The enumerator exposes the item keys, not the items themselves.
It took me a while to figure this out, so I feel your pain.

Bob Barrows
 
R

Roland Hall

in message
: Roland Hall wrote:
:
: >>> 2. Is it possible to use FOR...EACH, with a form and make the
: >>> variable an object?
: >>
: >> for each key in Request.Form
: >> Response.Write key & ": " & Response.Form(key)
: >> next
: >
: > key is the form element
:
: Actually, it is the key of the form element

Ah, ok.

: > Response.Form(key) would return the value but how can I make key an
: > object and use key.value to get the value?
: >
:
: Unfortunately, the vbscript enumerator does not work that way with these
: collections. The enumerator exposes the item keys, not the items
themselves.
: It took me a while to figure this out, so I feel your pain.

That's unfortunate. Well good for me that I have you to provide that answer
so my insanity will not come from trying to figure this one out. Thanks
Bob.

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
 

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

Similar Threads

ASP design question 4
Application question 2
Compressed Zipped Folder 6
VBScript function returning multiple values 17
Collect Excel Data from Website 5
screen scraping 4
the perfect function 4
replace text 2

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top