Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap

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

You are here: irt.org | FAQ | ASP | Q5818 [ previous next ]

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.


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

Select Case flag
Case 1 %>
<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>

<% Case 2
For each inputField in Request.Form
	For each inputValue in Request.Form(inputField)
		response.write inputField  & " = " & inputValue & "<

End Select

©2018 Martin Webb