Discussion Locked

Count selected objects in form field on

0 helpful
7 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
I have a form that has a scrolling text box with 20 names. I only want the user to be able to select 5 names. I am trying to write code that will pop up a dialog box that says "you can only select 5 names". I am also trying to run this when the client selects the Submit button.

7 replies

by e.rick

If you define a dropdown with your twenty names and set it to allow multiple selections you can determine the number of selected items with the Count property.

For example, if I have a SELECT field defined on my page called NameList, I can find out how many items are currently selected with the following statement:

Request.Form("NameList").Count

by al macintyre

I program in other languages, but I would either have the names in an array or subfile so that I could either count non-blanks or loop check for non-blank & exit at 6, then return text box to user with what they selected with your error message.

This discussion is closed to new replies.