title: How can I get a javascript variable text value in HTML lable tag
body: <p>I am trying to get a location coordinates by <code>onchange</code> event in javascript and I want to display a that coordinates in a label. I have tried following scenario I can get that coordinates by using alert box But I could not display on a label by using <code>document.getElementsByName("coordinates").innerHTML = text3;</code></p>
  
  <p>I have share my code below</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;%--
    Created by IntelliJ IDEA.
    User: rajee
    Date: 2/15/15
    Time: 1:19 PM
    To change this template use File | Settings | File Templates.
  --%&gt;
  &lt;%@ page contentType="text/html;charset=UTF-8" language="java" %&gt;
  &lt;html&gt;
  
  &lt;head&gt;
      &lt;title&gt;Create new Survey&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;h2&gt;simple survey form&lt;/h2&gt;
  &lt;form name="surveyform" method="post" action="CreateSurvey"&gt;
      &lt;table&gt;
          &lt;tr&gt;&lt;td&gt;Family  name:&lt;/td&gt;&lt;td&gt;&lt;input type="text" name="familyName"&gt;&lt;/td&gt;&lt;/tr&gt;
          &lt;tr&gt;&lt;td&gt;First  name:&lt;/td&gt;&lt;td&gt;&lt;input type="text" name="firstName"&gt;&lt;/td&gt;&lt;/tr&gt;
          &lt;tr&gt;&lt;td&gt;Middle  name:&lt;/td&gt;&lt;td&gt;&lt;input type="text" name="middleName"&gt;&lt;/td&gt;&lt;/tr&gt;
          &lt;tr&gt;&lt;td&gt;Gender:&lt;/td&gt;&lt;td&gt;&lt;input type="radio" name="sex" value="male" checked&gt;Male&lt;/td&gt;&lt;td&gt;&lt;input type="radio" name="sex" value="female"&gt;Female&lt;/td&gt;&lt;/tr&gt;
          &lt;tr&gt;&lt;td&gt;Birthday:&lt;/td&gt;&lt;td&gt;&lt;input type="date" name="dob"&gt;&lt;/td&gt;&lt;/tr&gt;
          &lt;tr&gt;&lt;td&gt;Income : A?B?C?D?&lt;/td&gt;&lt;td&gt;&lt;input type="text" name="income"&gt;&lt;/td&gt;&lt;/tr&gt;
          &lt;tr&gt;&lt;td&gt;Complete Address:&lt;/td&gt;&lt;td&gt;&lt;input type="text" name="address" id="address" onchange="codeAddress();"&gt;&lt;/td&gt;&lt;/tr&gt;
          &lt;tr&gt;&lt;td&gt;Coordinates:&lt;/td&gt;&lt;td&gt;&lt;label id="coordinates" name="coordinates"&gt;&lt;/label&gt;&lt;/td&gt;&lt;/tr&gt;
          &lt;tr&gt;&lt;td&gt;Mobile number:&lt;/td&gt;&lt;td&gt;&lt;input type="tel" name="mobileno"&gt;&lt;/td&gt;&lt;/tr&gt;
          &lt;tr&gt;&lt;td&gt;Email Address:&lt;/td&gt;&lt;td&gt;&lt;input type="email" name="email"&gt;&lt;/td&gt;&lt;/tr&gt;
          &lt;tr&gt;&lt;td&gt;Present internet provider:&lt;/td&gt;&lt;td&gt;&lt;input type="text" name="iprovider"&gt;&lt;/td&gt;&lt;/tr&gt;
          &lt;tr&gt;&lt;td&gt;Positive comments with present provider:&lt;/td&gt;&lt;td&gt;&lt;textarea name="comments" cols="40" rows="5"  &gt;&lt;/textarea&gt;&lt;/td&gt;&lt;/tr&gt;
          &lt;tr&gt;&lt;td&gt;Negative remarks with present provider:&lt;/td&gt;&lt;td&gt;&lt;textarea name="remarks" cols="40" rows="5" &gt;&lt;/textarea&gt;&lt;/td&gt;&lt;/tr&gt;
          &lt;tr&gt;&lt;td&gt;&lt;input type="submit" name="addsurvey" value="save survey details"&gt;&lt;/td&gt;&lt;td&gt;&lt;input type="reset" name="cancel" value="cancel"&gt;&lt;/td&gt;&lt;/tr&gt;
      &lt;/table&gt;
  
  &lt;/form&gt;
  
  &lt;/body&gt;
  &lt;script src="https://maps.googleapis.com/maps/api/js?v=3.exp&amp;signed_in=true"&gt;&lt;/script&gt;
  &lt;script runat=server&gt;
      var geocoder;
      var map;
      function initialize() {
          geocoder = new google.maps.Geocoder();
          var latlng = new google.maps.LatLng(-34.397, 150.644);
          var mapOptions = {
              zoom: 8,
              center: latlng
          }
          map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
      }
  
      function codeAddress() {
          var address = document.getElementById('address').value;
          geocoder.geocode( { 'address': address}, function(results, status) {
              if (status == google.maps.GeocoderStatus.OK) {
                  //alert(results[0].geometry.location);
                  var text3 = results[0].geometry.location;
                  alert(text3);
                  document.getElementsByName("coordinates").innerHTML = text3;
                  map.setCenter(results[0].geometry.location);
                  var marker = new google.maps.Marker({
                      map: map,
                      position: results[0].geometry.location
                  });
  
              } else {
                  alert('Geocode was not successful for the following reason: ' + status);
  
              }
          });
      }
  
      google.maps.event.addDomListener(window, 'load', initialize);
  
  &lt;/script&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>