cancel
Showing results for 
Search instead for 
Did you mean: 

How o get selected values from a multiselect listbox displayed in a text box

rnuma
Explorer
0 Kudos

Hi experts

I am trying to display the values of a multiselect list box in a text box. I have tried using the below script to achieve this and it is not working and I don't know what I am doing wrong.

if(SALES_TYPE_SELECT.getSelectedValues()=="Value1;value4"){
TEXT_4.setText("Daily Sales for EMEA");
}
if(SALES_TYPE_SELECT.getSelectedValues()=="Value2;value5"){
TEXT_4.setText("Daily Sales for APCA");
}
if(SALES_TYPE_SELECT.getSelectedValues()=="Value3"){
TEXT_4.setText("Daily Sales for Other");
}

Accepted Solutions (1)

Accepted Solutions (1)

MustafaBensan
Active Contributor
0 Kudos

Hi Robert,

Your code does not work because getSelectedValues() returns an array of strings and not a concatenated string. The following code should achieve the desired result:

var selectedSalesTypes = me.getSelectedValues();

var salesTypeString = "";

selectedSalesTypes.forEach(function(salesType, index) {
  salesTypeString = salesTypeString + salesType;
});

if (salesTypeString == "Value1Value4") {
	
	TEXT_4.setText("Daily Sales for EMEA");
	
} else if (salesTypeString == "Value2Value5") {
	
	TEXT_4.setText("Daily Sales for APCA");
	
} else if (salesTypeString == "Value3") {
	
	TEXT_4.setText("Daily Sales for Other");
	
}

Regards,

Mustafa.

rnuma
Explorer

Thanks for the support. It worked effortlessly

MustafaBensan
Active Contributor
0 Kudos

You're welcome. Glad it worked for you.

Answers (0)