We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How can i get the multi-selectbox selected text value ?

How can i get the multi-selectbox selected text value ?

value can but I need the selected text-value.


 codeList = respdata;

                var listObj = new ej.dropdowns.MultiSelect({

                    dataSource: codeList,

                    // maps the appropriate column to fields property

                    fields: { text: 'name', value: 'id' },

                    // set placeholder to MultiSelect input element

                    placeholder: "-선택-",

                    mode: "CheckBox",

                    width: "130px",

                   // select: onMultiSelectChange, // Bind the change event handler

                    showDropDownIcon: true,


                });

                listObj.appendTo('#rejectType');

                listObj.change = function (args) {

                    // args.value를 사용하여 선택된 항목들의 값을 가져옴

                    var selectedItems = args.text; // Get the selected items

                    var selectedItemsText = selectedItems.map(function (item) {

                        return item.name; // Get the text value of each selected item using 'name' field

                    });

                    var textarea = document.getElementById('rejectReason'); // Get the textarea element

                    textarea.value = selectedItemsText.join('');


                };



thank you.


1 Reply

UD UdhayaKumar Duraisamy Syncfusion Team May 11, 2023 01:59 PM UTC

You can obtain the text value of the selected item in the select event of the MultiSelect component. Additionally, we have prepared a sample and provided it below for your reference.


var checkList = new ej.dropdowns.MultiSelect({

  dataSource: window.ddCountryData,

  fields: { text: 'Name'value: 'Code' },

  placeholder: '-선택-',

  mode: 'CheckBox',

  width: '130px',

  showDropDownIcon: true,

  select: function (args) {

    var selectedItemsSpan = document.getElementById('selectedItems');

    var selectedItemText = args.itemData.Name;

    var currentSelectedItems = selectedItemsSpan.innerHTML;

    selectedItemsSpan.innerHTML =

      currentSelectedItems + selectedItemText + ', ';

  },

});

checkList.appendTo('#checkbox');




Documentation: https://ej2.syncfusion.com/javascript/documentation/api/multi-select/selectEventArgs/


Sample: https://stackblitz.com/edit/z6im35?file=index.js,index.html


Loader.
Live Chat Icon For mobile
Up arrow icon