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

205
Vistas
Remove previously selected dropdown items

I have a form that asks people to order something, lets just say "Red", "Blue", and "Green." Next to each color is a dropdown with the available order "1", "2", or "3".

If someone selects "2" for Red, I want to remove that option for the other colors that haven't been selected yet.

I'm not sure where to start. I am novice and have really only used HTML, CSS, and PHP although I have some javascript/jquery experience.

I'm messing around with the code below but need the "onchange" function to affect the SECOND dropdown and not the first...

function myFunction1() {
  var x = document.getElementById("mySelect");
  x.remove(x.selectedIndex);
}
<form>
  Select a fruit:
  <br>
  <select id="mySelect" onchange="myFunction1()">
    <option>Apple</option>
    <option>Pear</option>
    <option>Banana</option>
    <option>Orange</option>
  </select>
    <select id="mySelect2">
    <option>Apple</option>
    <option>Pear</option>
    <option>Banana</option>
    <option>Orange</option>
  </select>
</form>
<br>

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Not sure if this is what you are expecting:

function removeSelectedNumber() {
  var x = document.getElementById("numberSelect");
  x.remove(x.selectedIndex);
}
<form>
  Select a fruit:
  <br>
  <select id="colorSelect">
    <option>Red</option>
    <option>Green</option>
    <option>Blue</option>
    <option>Yellow</option>
  </select>
  <select id="numberSelect" onchange="removeSelectedNumber()">
    <option>1</option>
    <option>2</option>
    <option>3</option>
    <option>4</option>
  </select>
</form>
<br>

about 4 years ago · Juan Pablo Isaza 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