title: Javascript : Using Switch to set variables values for the function
body: <p>am totally new to Javascript , but i need it for using googlemaps in my project , am trying to set values for the latitude , longitude and map zoom for every certain city , so am getting the city name from a hidden form input and using Switch to switch regarding the city name . </p>
  
  <pre><code>cityDiv = document.getElementById('id_city');
  cityDiv.value = idCity ;
  
  switch (idCity)
  {
  case "city1":
      var map_long = 31.37667;
      var map_lat = 31.04306;
      var map_zoom = 3;
      break
  case "city2":
      var map_long = 31.33333;
      var map_lat = 29.85;
      var map_zoom = 7;
      break
  default:
      var map_long = 31.37667;
      var map_lat = 31.04306;
      var map_zoom = 3;
  }
  
  function onLoad() {
      map = new GMap(document.getElementById("map"));
      map.addControl(new GSmallMapControl());
      map.addControl(new GMapTypeControl());
      map.centerAndZoom(new GLatLng(map_lat,map_long) , map_zoom);
  
      GEvent.addListener(map, 'click', function(overlay, point) { 
          if (prev_pin) { 
              map.removeOverlay(prev_pin); 
              prev_pin = null; 
          } 
          //var yPoint = new YGeoPoint({{ place.latitude }},{{ place.longitude }});
  
          if (point) { 
              pin = new GMarker(point); 
              map.addOverlay(pin); 
              prev_pin = pin; 
  
              latDiv = document.getElementById('id_latitude');
              lngDiv = document.getElementById('id_longitude'); 
              lngDiv.value = point.x;
              latDiv.value = point.y; 
          } 
      });
  
  }
  </code></pre>
  
  <p>Sorry for this newbie question . </p>
  
  <p>Best regards .</p>
  
  <p>EDIT from comment by geowa4:</p>
  
  <p>The question and the problem are The Variables never set :( , so whats wrong with my code ?! i change "cityDiv.value = idCity ; " to " var idCity = cityDiv.value ; " which didn't work as well but this time the map refuses to load</p>