title: Add data in Input(box) to sql db through javascript
body: <p>Here is my code which I am using to write the data in input(box) "latitude" and "longitude" to database using c# code inside javascript.</p>
  
  <p>All I want is that the data gets inserted whenever the button is pressed. This code only inserts data once at the time of initialization. No effect occurs onButtonClick.</p>
  
  <pre><code>&lt;%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="Markers.WebForm1" %&gt;
  
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;style type="text/css"&gt;
    #google_map {width: 550px; height: 450px;margin-top:50px;margin-left:auto;margin-right:auto;}
  &lt;/style&gt;
  &lt;script type="text/javascript"
   src="https://maps.googleapis.com/maps/api/js?v=3.exp"&gt;
  &lt;/script&gt;
  &lt;script type="text/javascript"&gt;
  
      var mapCenter = new google.maps.LatLng(33.650077, 73.034054); //Google map Coordinates
      var map
      var marker
      var marker1
  
  
      function initialize() //function initializes Google map
      {
          var googleMapOptions =
          {
              center: mapCenter, // map center
              zoom: 15, //zoom level, 0 = earth view to higher value
              panControl: true, //enable pan Control
              zoomControl: true, //enable zoom control
              zoomControlOptions: {
                  style: google.maps.ZoomControlStyle.SMALL //zoom control size
              },
              scaleControl: true, // enable scale control
              mapTypeId: google.maps.MapTypeId.ROADMAP // google map type
          };
          map = new google.maps.Map(document.getElementById("google_map"), googleMapOptions);
          marker = new google.maps.Marker({
              position: mapCenter,
              map: map,
              draggable: true,
              animation: google.maps.Animation.DROP,
              title: "This a new marker!",
              icon: "http://maps.google.com/mapfiles/ms/micons/blue.png"
          });
          marker1 = new google.maps.Marker({
              position: mapCenter,
              map: map,
              draggable: true,
              animation: google.maps.Animation.DROP,
              title: "This a new marker!",
              icon: "http://maps.google.com/mapfiles/ms/micons/blue.png"
          });
          google.maps.event.addListener(marker, 'dragend', function (evt) {
              document.getElementById('latitude').value = evt.latLng.lat();
              document.getElementById('longitude').value = evt.latLng.lng();
  
          });
  
          google.maps.event.addListener(marker1, 'dragend', function (evt) {
              document.getElementById('latitude1').value = evt.latLng.lat();
              document.getElementById('longitude1').value = evt.latLng.lng();
          });
  
      }
      function addMyMarker() { //function that will add markers on button click
          &lt;%    Markers.DataClasses1DataContext db = new Markers.DataClasses1DataContext();%&gt;
          &lt;%    Markers.LocationDataPacket l = new Markers.LocationDataPacket(); %&gt;               
          &lt;%     l.cellPhoneGPSData = 1; %&gt;
          &lt;%      DateTime dt = DateTime.Now ;          %&gt;  
          &lt;%     l.Lat = Convert.ToDouble(latitude.Value.ToString());%&gt;
          &lt;%    l.time = dt; %&gt;
          &lt;%     l.Long = Convert.ToDouble(longitude.Value.ToString()); %&gt;
          &lt;%      db.LocationDataPackets.InsertOnSubmit(l); %&gt;
          &lt;% save(db);     %&gt;
      }
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body onLoad="initialize()"&gt;
  &lt;div id="google_map" &gt;&lt;/div&gt;&lt;button id="drop" onClick="addMyMarker()"&gt;Drop Markers&lt;/button&gt;
    &lt;input id="latitude" runat="server" value="3.33" /&gt;
    &lt;input id="longitude" type="text" runat="server" value="3.33" /&gt;
    &lt;input id="latitude1" type="text" value="3.33"/&gt;
    &lt;input id="longitude1" type="text" value="3.33"/&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I have no experience of coding in javascript.
  Any help will be highly appreciated.</p>