D
Doogie
Hi,
I have a listbox set up so users can select multiple choices. I want
to limit them so they can choose no more than 4 at a time. I have set
up javascript code to do the check on the number of choices selected
but what I want to do is if they choose more than 4 (i.e. 5), I want
to unselect the last item they selected. I cannot figure out how to
determine which was the last item selected.
function HasExceededMaximumYearWeekCount()
{
var count = 0;
for (index = 0; index < fmDetailQuery.lstYearWeek.options.length;
index++)
{
if (document.all.lstYearWeek.options(index).selected)
{
count++;
}
}
if (count > 4)
{
alert("You can only select a maximum of 4 year weeks at a
time.")
return false;
}
return true;
}
I have tried doing a check on this value:
fmDetailQuery.lstYearWeek.selectedIndex
but it always returns me the first item in the listbox that was
selected (i.e. the one at the top of the list that was selected). I
want the last item the user selected, is there a way to determine that?
I have a listbox set up so users can select multiple choices. I want
to limit them so they can choose no more than 4 at a time. I have set
up javascript code to do the check on the number of choices selected
but what I want to do is if they choose more than 4 (i.e. 5), I want
to unselect the last item they selected. I cannot figure out how to
determine which was the last item selected.
function HasExceededMaximumYearWeekCount()
{
var count = 0;
for (index = 0; index < fmDetailQuery.lstYearWeek.options.length;
index++)
{
if (document.all.lstYearWeek.options(index).selected)
{
count++;
}
}
if (count > 4)
{
alert("You can only select a maximum of 4 year weeks at a
time.")
return false;
}
return true;
}
I have tried doing a check on this value:
fmDetailQuery.lstYearWeek.selectedIndex
but it always returns me the first item in the listbox that was
selected (i.e. the one at the top of the list that was selected). I
want the last item the user selected, is there a way to determine that?