Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple select box

Status
Not open for further replies.

PerryG

Programmer
Joined
Aug 15, 2000
Messages
75
Location
US
Is there anyway to limit the # of selections from a select box to say 3 or 5 maximum selections?

Thanks.

PerryG [sig][/sig]
 
It can be done through coldfusion as well as javascript

Javascript : to be written in the onclick event of the select box cbomultiselect.

var myselections = form.cbomultiselect.value;
if (myselections.indexof(",") > 2)
alert("Only 3 selections allowed");


Coldfusion:

Submit the form.
In the target form try the following code.

<cfset selections=#form.cbomultiselect#>
<cfif FIND(#selections#,&quot;,&quot;,1) GT 2>
Only 3 selections allowed
</cfif> [sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top