button to run code

Discussion created by jay.kapalczynski on Feb 14, 2014
Latest reply on Feb 16, 2014 by stevel
I have been testing some examples from Java Script api help...Right now I have two different HTML pages and each is doing something different.

1.  On a user click in the map it buffers an area and then uses that buffer to select records and return to a table.
2.  I have an editor that on click in the map it selects the feature and brings up the edit window to edit attributes.

What I want is a couple buttons on my page that will run each of the tools above.  But I dont want to have to click the button every time, rather click it once and that code will run on each click until the user selects the other tool.
Any thoughts or examples?  Do I have to encapsulate each tools code in a Function and then have some sort of on button click for each button that runs the JS code? 
How would I keep that code running until another tool is selected?