Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Using a List Box to Allow Multiple Selections to Populate a Text Field


Level 1

Hi, I'm relatively new to Adobe LiveCycle Designer ES4 and writing javascript.  I'm having a hard time making my list box work and populate a text field.  

I want the user to be able to select multiple selections from the list box and those selections would populate in the text field.  Right now if the user selects an item from the list box and then selects another item from the list box, the previous selection is replaced by the new selection.

Here is the script I have.

form1.StatutesListBox::exit - (JavaScript, client)

SelectedStatutes.rawValue = "8 § 1324(a)(1)(A)(ii) Illegal transportation of an Alien";
SelectedStatutes.rawValue = "8 § 1326 Reentry of Deported Alien; Criminal penalties for reentry of certain Deported Aliens";
SelectedStatutes.rawValue = "18 § 2 Aiding and Abetting";
SelectedStatutes.rawValue = "18 § 4 Misprision of Felony";


Is there a way that I can have multiple items selected from the list box that will ALL populate in the text field?


Thanks for any help/advice you can provide.

1 Reply


Level 10

This is quite easy to accomplish.

When you exit a lst field, it returns a list of strings that you can turn into an array which can be processed by a loop to get the results.


var aSel = this.rawValue.split("\n"), // create an array from the selections in the list field
	// a reference array with a sub array containing the possible selection and the corresponding string going to be returned
        aStrings = [
		["2", "8 § 1324(a)(1)(A)(ii) Illegal transportation of an Alien"],
		["3", "8 § 1326 Reentry of Deported Alien; Criminal penalties for reentry of certain Deported Aliens"],
		["5", "18 § 2 Aiding and Abetting"]
	cResult = ""; // Empty result string

// Check every selection …
aSel.forEach(function (cSel) {
        // … against every string in the reference array
	aStrings.forEach(function (aString) {
		cResult += aString[0] === cSel ? aString[1].concat("\n") : "";
Textfield.rawValue = cResult; // Write results into textfield


Hope this helps.