Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

137
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda