title: Accessing Variables in Javascript
body: <p>I have the following code:</p>
  
  <pre><code>function getLocation() {
      if (navigator.geolocation) {
          navigator.geolocation.getCurrentPosition(showPosition);
      } 
      else { 
          alert('Geolocation is not supported by this browser');
      }
  }
  function showPosition(position) {
      alert(position.coords.latitude + ' ' + position.coords.longitude);
      var Loc = position.coords.latitude + ' ' + position.coords.longitude;
  }
  </code></pre>
  
  <p>I need to be able to access the Loc variable outside of the function or through the GetLocation Function. As i need to bind it into a grid that I am creating for storing clock on and off to work information for offsite employees.</p>
  
  <p>Here is the code that uses the variable Loc</p>
  
  <pre><code>getLocation();                      
                      var rowId=timesheetGrid.uid();
                      var pos = timesheetGrid.getRowsNum();
                      timesheetGrid.addRow(rowId,["","","","&lt;?php echo $ActiveWeek; ?&gt;","","","","","","","","","","",Loc],0); //adds a new row with pre filled data
                      timesheetGrid.selectCell(rowId,0,false,true,true); // Focus on the new row  
  </code></pre>
  
  <p>Any Help would be greatly appreciated</p>