Google Groups unterstützt keine neuen Usenet-Beiträge oder ‑Abos mehr. Bisherige Inhalte sind weiterhin sichtbar.

list box

46 Aufrufe
Direkt zur ersten ungelesenen Nachricht

NuB

ungelesen,
20.10.2005, 14:57:5020.10.05
an
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

ungelesen,
20.10.2005, 15:46:1720.10.05
an
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 neue Nachrichten