Well... I tried... its really irritating when perfectly valid action script
doesnt work :) so im only able to clear the whole thing when more than 3
items are selected...
var myObjArray = mylist.selectedItems; if (myObjArray.length > 3)
{alert("You may only choose 3 items form the list!"); mylist.selectedIndex =
null;}
Maybe you can get it from there or maybe someone else can help out.
selectedIndex is SUPPOSED to be the MOST recent selection in a multi select
list and it IS when you just view its value... but when you set it to
null... it clears the entire selectedIndex array... I tried :/
..:.:.:.:.:.:.:.:.:.:.:.:.:.:.
Bobby Hartsfield
http://acoderslife.com
-----Original Message-----
From: Bobby Hartsfield [mailto:[EMAIL PROTECTED]
Sent: Sunday, December 04, 2005 11:35 PM
To: CF-Talk
Subject: RE: Constraining cfselect
Here's a start on the action script...
<cfsavecontent variable="checkit_as">
var myObjArray = mylist.selectedItems; if (myObjArray.length > 3)
{alert("You may only choose 3 items form the list!");}
</cfsavecontent>
<cfform format="flash">
<cfselect name="mylist" query="tmp" display="thedisplay" value="thevalue"
multiple="yes" size="4" onchange="#checkit_as#" />
</cfform>
That will alert you anytime you make a selectionand the total number of
selected items are greater than 3. Still needs a method to deselect the item
when the alert is triggered.
...:.:.:.:.:.:.:.:.:.:.:.:.:.:.
Bobby Hartsfield
http://acoderslife.com
-----Original Message-----
From: Bobby Hartsfield [mailto:[EMAIL PROTECTED]
Sent: Sunday, December 04, 2005 6:07 PM
To: CF-Talk
Subject: RE: Constraining cfselect
Well, in a normal cfselect... you'd have to roll your own js for it...
something like this should work fine...
<script type="text/javascript">
var selConstraint = 3;
function doit(obj)
{
var selCount = 0;
for (i=0; i < obj.options.length; i++)
{
if ( obj.options[i].selected )
{
if (selCount < selConstraint)
{
selCount = selCount + 1;
}
else
{
obj.options[i].selected = false;
alert("You may only choose " + selConstraint
+ " items form the list.");
}
}
}
}
</script>
<form>
<select multiple onChange="doit(this)">
<option value="1">Option 1</option>
<option value="2">Option 2</option>
<option value="3">Option 3</option>
<option value="4">Option 4</option>
<option value="5">Option 5</option>
<option value="6">Option 6</option>
<option value="7">Option 7</option>
<option value="8">Option 8</option>
</select>
</form>
In a flash form, you'd have to roll your own action script to do it. I seem
to recall that actionscript has something like... selectedItems for a
dropdown list. That may return the number of selected items and make it
easier but I'd have to check that to make sure. Else, you'd have to do
basically the same thing that the javascript is doing above... loop over
each option and check it's 'selected' status while keeping a 'count' of how
many are selected. As soon as too many are selected, alert() the user and
deselect the rest.
Thats just quick and dirty though... ill probably think of a smoother way
as soon as I hit send ;^)
....:.:.:.:.:.:.:.:.:.:.:.:.:.:.
Bobby Hartsfield
http://acoderslife.com
-----Original Message-----
From: Saturday (Stuart Kidd) [mailto:[EMAIL PROTECTED]
Sent: Sunday, December 04, 2005 4:00 PM
To: CF-Talk
Subject: Constraining cfselect
Hi guys,
Does anyone know how to constrain the amount of selections in a
cfselect (multiple)? And more so especially in a flash form.
Thanks,
Saturday
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Find out how CFTicket can increase your company's customer support
efficiency by 100%
http://www.houseoffusion.com/banners/view.cfm?bannerid=49
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:226059
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54