Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

92
Vistas
How to toggle visibility of a Div element based on change events from two different select form fields

I am trying to toggle the visibility of a div element based on the values from two different select form fields.

The HTML select form fields have ids: #team and #country respectively.

I have so far tried:

let teamVal;
 document.getElementById("team").addEventListener("change", function (e) {
   teamVal= e.target.value;
 });

 let countryVal;
 document.getElementById("country").addEventListener("change", function (e) {
   countryVal = e.target.value;
 });

// a helper function that should toggle the div element with an id, #myDiv
function toggleDivVisibility(teamVal, countryVal) {
  console.log("Toggle method called!");

  const myDiv = document.getElementById("myDiv");

  if (teamVal === "firmino" && countryVal === "brazil") {
    myDiv.style.display = "none";
  } else {
    myDiv.style.display = "block";
  }
}

toggleDivVisibility(teamVal, countryVal);

Thus far, the method seems to be called on document load, however the implementation doesn't work.

Any assistance will be highly appreciated.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda