lundi 1 juin 2020

Copy selected multiple values to the text box

I have drop down list as below.

     <select id="checkOwner" multiple="multiple" onchange="copyValue()">
       <option value="FIRSTNAME">First Name</option>
       <option value="LASTNAME">Last Name</option>
     </select>

I used below javascript to copy selected value to text field.

function copyValue() {
  var dropboxvalue = document.getElementById('checkOwner').value;
  document.getElementById('mytextbox').value = dropboxvalue;
}

But the problem is, this copy only one value. I want to copy all the selected values. How can I do this?




Aucun commentaire:

Enregistrer un commentaire