title: Java Script Function Not Returning Value
body: <p>I have a java script function that return a string value, when i call this function on button click it return nothing.</p>
  
  <p>Here is my function code:</p>
  
  <pre><code>function PlotMap(StartLat, StartLog, EndLat, EndLog) {
  
  var map;
  var directionsDisplay;
  var directionsService = new google.maps.DirectionsService();
  var llList = "";
  
  function initMap() {
  
      map = new google.maps.Map(document.getElementById('map'), {
          center: { lat: StartLat, lng: StartLog },
          zoom: 15
      });
  
  
      directionsDisplay = new google.maps.DirectionsRenderer();
      directionsDisplay.setMap(map);
      calcRoute();
  
  } //End function initMap
  
  
  function calcRoute() {
      var start = new google.maps.LatLng(StartLat, StartLog);
      var end = new google.maps.LatLng(EndLat, EndLog);
      var bounds = new google.maps.LatLngBounds();
  
      bounds.extend(start);
      bounds.extend(end);
      map.fitBounds(bounds);
  
      var request = {
          origin: start,
          destination: end,
          travelMode: google.maps.TravelMode.DRIVING
      };
  
      directionsService.route(request, function (response, status) {
          if (status == google.maps.DirectionsStatus.OK) {
              directionsDisplay.setDirections(response);
              directionsDisplay.setMap(map);
  
              if (response.routes &amp;&amp; response.routes.length &gt; 0) {
                  var routes = response.routes;
                  for (var j = 0; j &lt; routes.length; j++) {
                      var points = routes[j].overview_path;
                      var ul = document.getElementById("vertex");
                      for (var i = 0; i &lt; points.length; i++) {
                          var li = document.createElement('li');
                          li.innerHTML = getLiText(points[i]);
                          ul.appendChild(li);
                          llList = llList + getLiText(points[i]) + " / ";
                      }
                  }
              }
          } else {
              alert("Directions Request from " + start.toUrlValue(6) + " to " + end.toUrlValue(6) + " failed: " + status);
          }
      });
  } //End function calcRoute
  
  function getLiText(point) {
      var lat = point.lat(),
          lng = point.lng();
      return "lat: " + lat + " lng: " + lng;
  }
  
  
  initMap();
  
  return llList;}
  </code></pre>
  
  <p>And Here i am calling this function on button click in asp.net page.</p>
  
  <pre><code>&lt;script&gt;
  
  function ii() {
  
      var tt = PlotMap(26.547648, 81.529472, 26.612515, 81.354248);
  
      alert(tt);
  }&lt;/script&gt;
  </code></pre>
  
  <p>Asp.net page code:</p>
  
  <pre><code>&lt;body&gt;
  &lt;input id="Button1" type="button" value="button" onclick="ii();"/&gt;
  &lt;div id="map" style="float: left; width: 70%; height: 400px;"&gt;&lt;/div&gt;
  &lt;ul id="vertex"&gt;
      &lt;li&gt;&lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p></p>
  
  <p>Everything works fine but function not returning any value. Please help i am new in web development. Thanks.</p>