 <p><code>id</code> is a global field, just do this:</p> <pre><code>document.getElementById("lat").innerHTML = "31"; document.getElementById("lon").innerHTML = "71"; </code></pre> <p>instead of what you have written.</p>