Persits Software, Inc. Knowledge Base Articles

Upload.Form returns only the first selected item of a multi-select control

Problem Description

When retrieving values from a multi-select control such as <SELECT NAME="Choice" MULTIPLE> using AspUpload, the collection Upload.Form, unlike Request.Form, only returns the first selected value.

An attempt to reference additional values using an expression such as

val = Upload.Form("Choice")(1)

generates the following error:

Microsoft VBScript runtime (0x800A01C3)
Object not a collection: '[object]'

Solution

Although the collection Upload.Form is not identical to Request.Form, you can still use it to retrieve all selected values from a multi-select control.

Upload.Form stores all selected values from a multi-select control as separate items, but under the same name. The following code snippet prints out all selected items from the control <SELECT NAME="Choice" MULTIPLE> :

<%
For Each Item in Upload.Form
  If Item.Name = "Choice" Then Response.Write Item.Value
Next
%>