Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

74
Views
In a <select multiple> tag, how to put the values from selected <option> tags to an array?

I have this code:

<select multiple id="test">
  <option value="A">Option A</option>
  <option value="B">Option B</option>
  <option value="C">Option C</option>
  <option value="D">Option D</option>
</select>

If the user selects A and C, is there a way to put those values in an array? If the select is not multiple, I can use option = document.getElementById('test').value;. But if it's multiple then I don't know how to do it. Because we can only use one value attribute, not an array of attributes. The documentations for <option> and <select> aren't useful. There is also a similar question but I'm not sure how to apply it.

What I want is to put them into a string:

string = 'You select` + optionarray[0] + ' and ' + optionarray[1] + ' and ' + optionarray[2] + ... //until there is no more element left
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!