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

327
Views
¿Cómo puedo hacer un <select> con opciones que habilitan/deshabilitan un botón?

Estoy tratando de hacer una pregunta de opción múltiple que, cuando se selecciona la respuesta correcta, activa un botón

 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> </select> <button id="btton" type="button" disabled>button</button>

about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

Cambie ansposible!=1 a ansposible!==1

También use possibleAns ===1 en otra declaración

about 4 years ago · Juan Pablo Isaza Report

0

En else if (possibleAns = 1) { , (possibleAns = 1) es una instrucción de asignación. Use else if (possibleAns == 1) { para verificar la igualdad.

about 4 years ago · Juan Pablo Isaza Report

0

Una forma más limpia de codificar eso (en mi humilde opinión).

 const select_element = document.getElementById('question') , button_element = document.getElementById("btton") ; select_element.onchange = () => { button_element.disabled = (select_element.value != '1') }
 <select id="question"> <option value="0">wrong answer</option> <option value="1">right answer</option> <option value="2">wrong answer</option> </select> <button id="btton" type="button" disabled> button </button>

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!