Select to view content in your preferred language

toggling function on and off

719
1
06-29-2012 08:35 AM
ChrisBerryman1
Emerging Contributor
I am trying to write a function that will allow me to turn a function off with a checkbox. 

here is my code:

jQuery("#centeronCurrentLocationCheckBox").change(function() {
  if(showLocation == 0){
    showLocation = 1;
   }else{ 
    showLocation = 0;
   alert("hi");
   }   
  }); 


I have another working checkbox that does the same as this, so I thought I would recreate it with just different titles for the function and id name. 

I also created a event handler function for this as well, but when I did, my map did not show up at all and I got an error that was located in the arcgis javascript api.

any suggestions as to how to create the code to turn this function on and off?
0 Kudos
1 Reply
HemingZhu
Frequent Contributor
I am trying to write a function that will allow me to turn a function off with a checkbox. 

here is my code:

jQuery("#centeronCurrentLocationCheckBox").change(function() {
  if(showLocation == 0){
    showLocation = 1;
   }else{ 
    showLocation = 0;
   alert("hi");
   }   
  }); 


I have another working checkbox that does the same as this, so I thought I would recreate it with just different titles for the function and id name. 

I also created a event handler function for this as well, but when I did, my map did not show up at all and I got an error that was located in the arcgis javascript api.

any suggestions as to how to create the code to turn this function on and off?


Why just use onchange handler with a variable to handler the situation using return statment? something like this:
function checkboxChanged(sender, evt)
{
      if variable...
         return;      // equal to cancel
     else
         do something...
}
0 Kudos