Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

Q5818 What's a collection and how does it help ASP?

irt.org | Knowledge Base | ASP | Q5818 [ previous next ]

Q5818 What's a collection and how does it help ASP?

Collections are simply groups of objects, giving you, the programmer, an easy way to make reference to each member of that collection.

In the example, regardless of whether the form changes, all the fields will be displayed because they are referenced using the Request.Form collection.

Notice that each field (Request.Form(inputField)) is ALSO a collection. In the example form the hidden value input 'car' has two values assigned to it, each will be treated separately, because I enumerate each member of the fields' value collection.

<html>
<head>
</head>
<body>

<%
'
flag = Request.Form("flag")
If flag = "" Then
	flag = 1
End If

Select Case flag
Case 1 %>
<!-- FORM ON THE SUBMITTING PAGE //-->
<form action='forms2.asp' name='enrollStudent' method='post'>
<input type='text' size = '25' name='firstName'>
<input type='text' size = '25' name='lastName'>
<input type='checkbox' name='enrolled'>
<input type='submit' name='submitted' value='true'>
<input type='hidden' name='status' value='potentialStudent'>
<input type='hidden' name='flag' value='2'>
<input type='hidden' name='car' value='Mercedes'>
<input type='hidden' name='car' value='Ford>

</form>
<% Case 2
For each inputField in Request.Form
	For each inputValue in Request.Form(inputField)
		response.write inputField  & " = " & inputValue & "<
		br>"
	Next
Next

End Select
%>
</body>
</html>

Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.