This content has been archived and is no longer being maintained.

Table of Contents


Example: Selecting all of the entries in a list box that is on a webpage

The methods and properties for changing the selected entry on multiselect HTML list boxes only allow you to select one entry. There is no simple way to perform a Select All action.

To work around this limitation, use the ExecuteScript method off of the webpage. To do this, your list box must meet these requirements:

  • It must be an HTML Select element
  • It must have an ID

If you run the following script in an ExecuteScript method call, the system selects all of the list box items:

var listbox = document.getElementById("<i>elementid</i>");
var options = listbox.options;

for (var index = 0; index < options.length; index++)
    options[index].selected = true;
In the example script, replace <i>elementid </i>with the ID of your list box.

For more information on the ExecuteScript method, see Web Page Properties, Methods, and Events.

Published November 14, 2016 — Updated May 24, 2018

25% found this useful

Have a question? Get answers now.

Visit the Pega Support Community to ask questions, engage in discussions, and help others.