title: How do I Redirect to an url with variables in JavaScript?
body: <p>I need to calculate the distance between two places by using google maps API. 
  they provide the distance by this url :</p>
  
  <p><a href="https://maps.googleapis.com/maps/api/distancematrix/json?units=imperial&amp;origins=STARTING_PLACE&amp;destinations=ENDING_PLACE&amp;key=YOUR_KEY" rel="nofollow noreferrer">https://maps.googleapis.com/maps/api/distancematrix/json?units=imperial&amp;origins=STARTING_PLACE&amp;destinations=ENDING_PLACE&amp;key=YOUR_KEY</a></p>
  
  <p>I have two HTML text inputs to enter starting place and ending place</p>
  
  <pre><code>&lt;input id="origin-input" type="text" placeholder="Enter an origin location"&gt;
  &lt;input id="destination-input" type="text" placeholder="Enter a destination location"&gt;
  </code></pre>
  
  <p>Then I have a JavaScript fuction to create the url</p>
  
  <pre><code>function distcalc()
  {
  var org = document.getElementById('origin-input');
  var dest = document.getElementById('destination-input');
  window.location = 'https://maps.googleapis.com/maps/api/distancematrix/json?units=imperial&amp;origins='+org+'&amp;destinations='+dest+'&amp;key=YOUR_KEY';
  }
  </code></pre>
  
  <p>when I call this function, browser can't find values for origins and destinations parameters in the url.</p>
  
  <p>How I solve this??</p>