Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
Select All in a Multiple Selection List
dlukezic
Hi everyone! Has anyone ever tried to create some sort of "Select All" function for a multiple selection list so that the user doesn't have to scroll through the entire list to select everything? If anyone has, can you share with me how you did it?
Thanks,
Doreen
Find more posts tagged with
Comments
Adam Stoller
Have you tried selecting one entry and then hitting Ctrl-A (or Command-A on Mac's)? Or is that not what you're looking for?
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
dlukezic
Hi! Actually, when I select one entry and then hit ctrl-a, all of the labels on the DCT get selected. It's very strange behaviour.
Doreen
Adam Stoller
Hmm - not sure what to recommend then - sorry.
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
Migrateduser
Select first, shift-ctrl-end?
dlukezic
Thanks! It works great!
Doreen
dlukezic
Hi everyone! I decided to try another approach with this and I am stuck. I am using the following code to have a checkbox that allows the user to select all the items in the multi-select list. So, if the user checks the checkbox, all items in the list should be selected. Here is the code:
function selectAll() {
var citySelectAll = IWDatacapture.getItem("/citySelectAll");
var city = IWDatacapture.getItem("/city");
var cityLength = city.getOptions().length;
if ((citySelectAll.getValue() == 0) && (citySelectAll.getValue() != "")) {
for (var i = 0; i < cityLength+1; i++) {
city.setValue(
);
}
IWDatacapture.redraw();
}
else {
alert("in the else");
}
}
I also tried it by replacing the entire for loop with city.setValue([0, cityLength]);
Unfortunately, regardless of which way I do it, the options do not get selected. Does anyone know what I am doing wrong?
Thanks!
Doreen
Adam Stoller
Try posting the code again - but when doing so - select "Using HTML" from the "Make post" drop-down above the text area where you past the text.
The default formatting treats
, and perhaps (i) as if it were the same thing as <i> - in other words, it begins italics, and doesn't show the 'i' where it was supposed to be.
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
dlukezic
Sorry about that! Here's the code again:
function selectAll() {
var citySelectAll = IWDatacapture.getItem("/citySelectAll");
var city = IWDatacapture.getItem("/city");
var cityLength = city.getOptions().length;
if ((citySelectAll.getValue() == 0) && (citySelectAll.getValue() != "")) {
for (var i = 0; i < cityLength+1; i++) {
city.setValue(
);
}
IWDatacapture.redraw();
}
else {
alert("in the else");
}
}
Thanks for your help in advance!
Doreen
Adam Stoller
Somehow I don't think that
city.SetValue(
);
is correct. Perhaps
city
.setValue(1);
(just guessing off the top of my head here)
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
Migrateduser
Not sure why you would do that or what the other logic is, but can't you just iterate over item.getOptions and set each one's selected property to true?
dlukezic
I was trying what I had because according to the FormAPI documentation, I should be able to do that.
However, I am happy to try something else. I can't seem to get the syntax right for what you are suggesting though. Would you be able to give me an example?
Thanks very much!
Doreen
TestReportWithGrouping.rptdesign
Migrateduser
I don't think you need /citySelectAll - you can have a callout invoke your FormAPI function. Not sure if callouts are supported on multiselect lists though, or what versions. I think the code would be something like:
IWEventRegistry.addItemHandler( '/city', 'onCallout', handleCityCallout );
function handleCityCallout( item )
{
return( selectAll( item ));
}
function selectAll( item )
{
for( var i = 0 ; i < item.getOptions().length ; i++ )
{
item.getOptions()[ i ].selected = true;
}
return( true );
}
Edited by john on 07/21/04 12:38 PM (server time).
dlukezic
For anyone who is interested, here is the code that I ended up with:
function selectAll() {
var citySelectAll = IWDatacapture.getItem("/citySelectAll");
var city = IWDatacapture.getItem("/city");
var cityOptions = city.getOptions();
var cityLength = city.getOptions().length;
if ((citySelectAll.getValue() == 0) && (citySelectAll.getValue() != "")) {
var commandString = "IWDatacapture.getItem(\"/city\").setValue([";
for (var i=0; i