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

136
Vistas
Javascript activating/deactivating functions based on selection

I am developing a web map. This map should include two tools (layerswipe and layerspy) for the user to explore differences between two overlayed layers.

My goal is to create two radio buttons where one of the tool gets activated when the corresponding radio button is selected.

The radio buttons:

<div class="toolbar-centered">
        <input type="radio" id="swipelayer" name = "mainfunction" onclick="mainfunx()" > Swipe
        <input type="radio" id="layerspy" name = "mainfunction" onclick="mainfunx()"> Layer spy
</div>

My javascript function to change between the two tools (tools are defined as swipefunction() and spyfunction()):

function mainfunx() {
 var s = document.getElementById('swipelayer').checked,
     p = document.getElementById('layerspy').checked;
 if (s) swipefunction()
 if (p) spyfunction()
}

Once I change my selection on the radio buttons, the tools do not get deactivated. Instead both are activated at the same time. I am very new to Javascript and do not really have a clue how to make sure that the other function is deactivated while the other is activated.

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