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

206
Views
¿Cómo puedo mostrar una ventana diferente dependiendo de la opción que elijo de un combo de selección?

tengo este codigo

Y quiero mostrar un mensaje diferente cuando hago clic en una de estas opciones.

 document.getElementById("specialityAppointmentSelection").addEventListener('onchange', function(){ let specialityAppointmentSelection = document.getElementById("specialityAppointmentSelection"); let specialityOption = specialityAppointmentSelection.value; console.log(specialityOption); if(specialityOption === "1"){ console.log("medicina"); } else { console.log("enfermería"); } });
 <p>Selecciona el tipo de cita que desee: </p> <select id = "specialityAppointmentSelection"> <option value = "1">Medicina</option> <option value = "2">Enfermería</option> </select>

Pero no puedo mostrar nada en mi console.log , ¿cuál es el problema?

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

0

Debería usar change en lugar de onchange así .addEventListener('change', function(){

 document.getElementById("specialityAppointmentSelection").addEventListener('change', function(){ let specialityAppointmentSelection = document.getElementById("specialityAppointmentSelection"); let specialityOption = specialityAppointmentSelection.value; console.log(specialityOption); if(specialityOption === "1"){ console.log("medicina"); } else { console.log("enfermería"); } });
 <p>Selecciona el tipo de cita que desee: </p> <select id = "specialityAppointmentSelection"> <option value = "1">Medicina</option> <option value = "2">Enfermería</option> </select>

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!