title: Adding unique info windows to markers and updating a database to store the info (google map api)
body: <p>I am currently coding a travel website that will allow a user to click on a map, resulting in a marker going into that location. From here I wish for the user to apply an info window to that particular marker with details such as Country, City, Duration, Comments. However when I code this, the info window will appear but the data is not unique, the data the user enters and saves shows over the next marker the exact same. So for example, say the user clicks Ireland, when they click England, and go to edit that marker the marker will have all the Ireland information in it. How do i make this unique?</p>
  
  <p>here is my HTML code:</p>
  
  <pre><code>function initialize() {
    var latlng = new google.maps.LatLng(54.5, -7.0);
    var options = {
      zoom: 7,
      center: latlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    }
    var map = new google.maps.Map(document.getElementById("map"), options);
    var html = "&lt;table&gt;" +
               "&lt;tr&gt;&lt;td&gt;Country:&lt;/td&gt; &lt;td&gt;&lt;input type='text' id='country'/&gt; &lt;/td&gt; &lt;/tr&gt;" +
               "&lt;tr&gt;&lt;td&gt;City:&lt;/td&gt; &lt;td&gt;&lt;input type='text' id='city'/&gt;&lt;/td&gt; &lt;/tr&gt;" +
               "&lt;tr&gt;&lt;td&gt;Duration:&lt;/td&gt; &lt;td&gt;&lt;input type='text' id='duration'/&gt;&lt;/td&gt; &lt;/tr&gt;" +
               "&lt;tr&gt;&lt;td&gt;Category:&lt;/td&gt; &lt;td&gt;&lt;select id='category'&gt;" +
                  "&lt;option value='city' SELECTED&gt;City Break&lt;/option&gt;" +
                  "&lt;option value='beach'&gt;Beach Holiday&lt;/option&gt;" +
                  "&lt;option value='romantic'&gt;Romantic Holiday&lt;/option&gt;" +
                  "&lt;option value='activity'&gt;Activity Holiday&lt;/option&gt;" +
                  "&lt;option value='site'&gt;Site Seeing&lt;/option&gt;" +
                  "&lt;/select&gt; &lt;/td&gt;&lt;/tr&gt;" +
               "&lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;input type='button' value='Save &amp; Close' onclick='saveData()'/&gt;&lt;/td&gt;&lt;/tr&gt;";
  infowindow = new google.maps.InfoWindow({
   content: html
  });
  
  google.maps.event.addListener(map, "click", function(event) {
      marker = new google.maps.Marker({
        position: event.latLng,
        map: map
      });
      google.maps.event.addListener(marker, "click", function() {
        infowindow.open(map, marker);
      });
  });
  }
  
  function saveData() {
    var country = escape(document.getElementById("country").value);
    var duration = escape(document.getElementById("duration").value);
    var category = document.getElementById("category").value;
    var latlng = marker.getPosition();
  
    var url = "phpsqlinfo_addrow.php?country=" + country +  "&amp;city" + city + "&amp;duration=" + duration +
              "&amp;category=" + category + "&amp;lat=" + latlng.lat() + "&amp;lng=" + latlng.lng();
    downloadUrl(url, function(data, responseCode) {
      if (responseCode == 200 &amp;&amp; data.length &gt;= 1) {
        infowindow.close();
        document.getElementById("message").innerHTML = "Location added.";
      }
    });
  }
  
  function downloadUrl(url, callback) {
    var request = window.ActiveXObject ?
        new ActiveXObject('Microsoft.XMLHTTP') :
        new XMLHttpRequest;
  
    request.onreadystatechange = function() {
      if (request.readyState == 4) {
        request.onreadystatechange = doNothing;
        callback(request.responseText, request.status);
      }
    };
  
    request.open('GET', url, true);
    request.send(null);
  }
  
  function doNothing() {}
  &lt;/script&gt;
  </code></pre>