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

135
Views
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
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!