Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

204
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda