display array value in select box in JavaScript

Viewed 98

Can you actually display array value in the <select> but not in the option list ? What I mean here is assuming I already read the value from the API, and I want to retrieve it and displayed it like in this expected output.

Expected output

But with my code I got it like this.

I want to display all 3 value in the highlighted area. Is that possible to do so ? my output


 let staff_assign= '';
   e.staff_user.assign.map((e) => {
      staff_assign+= `<option value="${e.staff_id }">${e.staff_name}</option>`;
 });

----------------------------------------------------------
<div class="form-control-wrap">
  <select id="getStaff" multiple="multiple">
    ${staff_assign}
  </select>
</div>


Just explanations will do.

1 Answers
Related