Select to view content in your preferred language

Stuck on a radio button?

963
2
02-24-2012 10:26 AM
evanpicard
Emerging Contributor
Ive got a radio button:

            <form id="myform" >
                <H3>Select</H3>
                <input type="radio" name="selectingTool" id="radioOne" checked value="District"/> <label for="radioOne">District</label> <br />
                <input type="radio" name="selectingTool" id="radioTwo" value="Division"/> <label for="radioTwo">Division</label> <br />
                <button id="buttonbutton" onclick=searchChoice()>Apply</button>
            </form>


I want to use this  to select which layer is queried:
        function searchChoice() {
          alert(dojo.byId("radioOne").value);
              switch (dojo.byId("selectingTool").value) {
              case "District":
                dojo.connect(districtLayer, 'onClick', function(evt){
                  alert("hi");
                  //select the clicked feature

                  var query = new esri.tasks.Query();
                  query.geometry = evt.mapPoint;
                  districtLayer.selectFeatures(query, esri.layers.FeatureLayer.SELECTION_NEW);
                }); //end of onClick...
                break;
              case "Division":
                dojo.connect(divisionLayer, 'onClick', function(evt){
                  //select the clicked feature
                  var query = new esri.tasks.Query();
                  query.geometry = evt.mapPoint;
                  divisionLayer.selectFeatures(query, esri.layers.FeatureLayer.SELECTION_NEW);
                }); //end of onClick...
                break;
            };  
        };         
      


Instead of any of that  the whole page redraws. why does it redraw?!
in 1 or 2 of my 1000 or so attempts I've gotten the value of the selecting tool to change to "district" but never division.
Sorry if its a little messy, ive changed things back and forth 1000 times today.
And, how do I get to radioTwo??!


Please help.
Thank you,
Evan
0 Kudos
2 Replies
derekswingley1
Deactivated User
Your form is probably being submitted which causes the page to reload. Either ditch the form (you can just use input tags and a button) or use preventDefault().
0 Kudos
evanpicard
Emerging Contributor
Your form is probably being submitted which causes the page to reload. Either ditch the form (you can just use input tags and a button) or use preventDefault().

Thank you. That certainly got rid of the refresh, but I still can't get into the switch statement. Any idea? I must be missing something.
Thanks for the help.
Evan.
0 Kudos