Skip to Content

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

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Nov 08, 2017 at 09:09 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded