Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

151
Views
I want to get Origin from my input with the id "input_search". How can i do it it?

So i tried to solve this problem by doing

document.getElementbyId('seach_input') but it doesnt work

here my code:

var autocomplete = new google.maps.places.Autocomplete(document.getElementById("search_input"), 
{
    componentRestrictions: {'country' : ['AT']},
    fields: ['geometry', 'name'],
    types: ['establishment', 'geocode']
})

var directionsService = new google.maps.DirectionsService();

var request = {
  origin      : 'Imst, Österreich', // a city, full address, landmark etc
  destination : 'Innsbruck, Österreich',
  travelMode  : google.maps.DirectionsTravelMode.DRIVING
};

function getRoute(){
    directionsService.route(request, function(response, status) {
  if ( status == google.maps.DirectionsStatus.OK ) {

document.getElementById('preis').value = Math.round(response.routes[0].legs[0].distance.value / 1000 * 2) // the distance in metres
  }
  else {
    // oops, there's no route between these two locations
    // every time this happens, a kitten dies
    // so please, ensure your address is formatted properly
  }
});

}
<input type="text" required="" class="inputText" id="search_input" name="o" placeholder="Abholort"> <br> 

<input type="text" name="preis" readonly="" class="inputText" id="preis" placeholder="preis"><br>

        <button id="preisA" onclick="getRoute()" class="toggle-btn">Preis ausrechnen!</button>

i want in var request the origin text to be de value of the input text with the id "search_input" how can i do it?

about 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!