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

209
Views
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 answers
Answer question

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 Report
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!