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.
<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>