How ca i make a <select> with options that enable/disable a button


i’m trying to do a multiple choice question that when selected the right answer enable a button

function enAble() {
  let possibleAns = document.getElementById('question').value;

  if (possibleAns != 1) {
    document.getElementById("btton").disabled = true;
  } else if (possibleAns = 1) {
    document.getElementById("btton").disabled = false;
<select id="question" onchange="enAble()">
  <option>wrong answer</option>
  <option value="1">right answer</option>
  <option>wrong answer</option>

<button id="btton" type="button" disabled>button</button>


In else if (possibleAns = 1) {, (possibleAns = 1) is an assignment statement. Use else if (possibleAns == 1) { to check for equality.

Answered By – user1599011

Answer Checked By – Mary Flores (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.