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

191
Vistas
<button type="submit"> not working on mobile devices

I have this form which shows the user how far an address is from the city of Silkeborg in Denmark by using Google Maps.

The first input field is address and the second one is zipcode.

The form can be seen here: https://silkeborgkalder.eistrupweb.dk/job-i-silkeborg/

On desktop the form works as it should. However, on mobile devices nothing happens when I fill out the form and hit the submit button "Vis afstand" (Show distance).

When submitted the following Javascript is executed:

function vejviser() {
  var adresse = document.getElementById("adresse");
  var by = document.getElementById("by");
  window.open("https://www.google.com/maps/dir/?api=1&origin=Silkeborg&destination=" + adresse.value + "+" + by.value + "&travelmode=driving")
}
<form id="jobDistanceCalculator">
  <input id="adresse" class="input-felt" type="text" placeholder="Arbejdspladsens adresse" name="adresse" /><br />
  <input id="by" class="input-felt" type="number" placeholder="Arbejdspladsens postnummer" name="postnummer" /><br />
  <button type="submit" class="submit-btn" value="Vis afstand">Vis afstand</button>
</form>

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Apart from the error from the gaTracker, it seems you are missing an event listener

window.addEventListener("load", function() {
  document.getElementById("jobDistanceCalculator").addEventListener("load", function(e) {
    e.preventDefault(); // stop submission
    var adresse = document.getElementById("adresse");
    var by = document.getElementById("by");
    window.open("https://www.google.com/maps/dir/?api=1&origin=Silkeborg&destination=" + adresse.value + "+" + by.value + "&travelmode=driving")
  })
})
<form id="jobDistanceCalculator">
  <input id="adresse" class="input-felt" type="text" placeholder="Arbejdspladsens adresse" name="adresse" /><br />
  <input id="by" class="input-felt" type="number" placeholder="Arbejdspladsens postnummer" name="postnummer" /><br />
  <button type="submit" class="submit-btn" value="Vis afstand">Vis afstand</button>
</form>

But why a script?

<form id="jobDistanceCalculator" action="https://www.google.com/maps/dir/">
  <input type="hidden" name="api" value="1" />
  <input type="hidden" name="origin" value="Silkeborg" />
  <input type="hidden" name="travelmode" value="driving" />

  <input name="destination" class="input-felt" type="text" placeholder="Arbejdspladsens adresse og post nummer" /><br />
  <button type="submit" class="submit-btn" value="Vis afstand">Vis afstand</button>
</form>

about 4 years ago · Juan Pablo Isaza Denunciar
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