Skip to Content
0

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

Nov 08, 2017 at 05:00 AM

37

avatar image

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");
}

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Mustafa Bensan Nov 08, 2017 at 09:09 AM
0

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.

Show 2 Share
10 |10000 characters needed characters left characters exceeded

Thanks for the support. It worked effortlessly

1

You're welcome. Glad it worked for you.

0