Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

170
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda