Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

list box

46 views
Skip to first unread message

NuB

unread,
Oct 20, 2005, 2:57:50 PM10/20/05
to
I have a list box that is populated from my dataset. I add a new item in
there called "ALL". In this list box the user can select more then one item,
my question is, if they select ALL can i disable the multi selection
capability? So if ALL is selected they can't hold down the CTRL key and
select more.

Sreejith Ram

unread,
Oct 20, 2005, 3:46:17 PM10/20/05
to
I believe, there is no builtin property in listbox control for this

but, this is simple to implement in javascript.. you will not be able to
disable some options in a select box but will be able to deselect the other
selections or display a message if ALL is selected.

Following function would deselect all except first item in the list...

function Deselect()
{
var theDayElement = window.document.form1.cmbDay

var optionCounter;
for (optionCounter = 1; optionCounter < theDayElement.length;
optionCounter++)
{
theDayElement.options[optionCounter].selected=false;
}
}

This function would check if first option (ALL) is selected and call
deselect() to deselect all other options

function CheckValue()
{
if( window.document.form1.cmbDay.options[0].selected == true)
DeselectAll();
}

your Select tag would look like below

<SELECT NAME="cmbDay" ID="cmbDay" multiple onchange="CheckValue();">


Hope this helps....

0 new messages