Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

78
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda