[SOLVED] Smart select value

Hello, all !
Help me, please.

How can i get array of index multiple selected items from smart select object?
Example, this code returned only the name of selected items

app.smartSelect.get('.smart-select').valueEl

how i’ll get array of index this names

code html is:

                  <a class="item-link smart-select smart-select-init">
                    <select name="options">
                      <option value="1" selected>Option1</option>
                      <option value="2">Option2</option>
                      <option value="3">Option3</option>
                       ...
                      <option value="16">Option16</option>
                    </select>
                    <div class="item-content">
                      <div class="item-inner">
                        <div class="item-title">Options</div>
                      </div>
                    </div>
                  </a>

i want have a array of selected values, like [1,2,3,7]
i havn’t ideas

thanks I got it !

var smartSelectOptions = app.smartSelect.get('.smart-select').$selectEl[0].options;
var selectOptionsArray=[];
for(var x=0; x<smartSelectOptions.length; x++){
  if (smartSelectOptions[x].selected){
   selectOptionsArray.push(smartSelectOptions[x].value);
  };
};

It also could be just:

app.smartSelect.get('.smart-select').$selectEl.val();

It will return an array with selected options values

1 Like

Found the option even easier. At first, I looked at the object incorrectly, did not specify a name.

 $$('#smartSelectId').val()

It’s returned array of items

1 Like

How can I get the text from the option?
Have tried:
$selectEl.text();
$selectEl.option();
$selectEl.innerHtml();

But with no luck :frowning:

Sorry, I found something to work on here: