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

88
Vistas
javascript select the second option automatically?

How can I use javascript, to automatically select Option value 2? But I have and as the same id ..

var index = 1; /* option do select*/
document.getElementById("594951-Cor").options.selectedIndex = index;
<div id="594951-Cor" name="594951-Cor">

<select id="594951-Cor" name="594951-Cor" class="">
<option value="0">Selecione...</option>
<option value="1">Color 01</option>
<option value="2">Color 02</option>
</select>

</div>

about 4 years ago · Santiago Gelvez
1 Respuestas
Responde la pregunta

0

After solve the problem with ID's (change the duplicated id's), if you want to select by value, just assign on the select node:

document.getElementById("594951-Cor").value = "2";

assuming that you want to select <option value="2">Color 02</option> and the id of the select node is "594951-Cor".

The "2" is the value of the `option, not the index.

about 4 years ago · Santiago Gelvez Denunciar
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