O
O
Oleg Sevoc2020-05-12 19:28:58
JavaScript
Oleg Sevoc, 2020-05-12 19:28:58

How to disable select?

How to disable the other when changing the value in one select?
For example, so that when the third item is selected in the first select, the neighboring select is not available at all, and if you change it to two or one, everything turns back on.
https://codepen.io/oldschool1705/pen/pojKMBg

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
MagicMight, 2020-05-12
@mrgreeg7

<select onchange="checkValue(this.value)">
  <option> Один</option>
  <option> два</option>
  <option> три</option>
  </select>
<select id="abc">
  <option> выкл</option>
  <option> выкл</option>
  <option> выкл</option>
</select>

const checkValue = val => {
    document.getElementById('abc').disabled = val === 'три';
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question