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

210
Vistas
Javascript function does not execute on page load but executes when called from Console Window

I have a javascript function to append options on a select input field. Below is code snippet:

function loadZoneDropDown(){
    var datas = placesZoneData.zones, a = document.getElementById("route_start_point");
    for(let t in datas){
        var value_data = datas[t];
            $('#route_start_point').append('<option value="'+t+'">'+value_data.data["name"]+'</option>');
        
    }
    sortSelectList(a);
}

This function is called inside a load() function on the <body> tag as below:

function load(){
   //otherFunctions();
    loadZoneDropDown();
}

HTML code:

<html>
  <head></head>
  <body onload="load()">
  </body>
</html>

The page loads and No new option is appended to the #route_start_point select field. When I run the same function directly on console, the script executes and the options are populated. Can you help me figure the problem out. Note that otherFunctions() are running very OK and fine on the webpage. Screenshot of code before console run

Screenshot after console execution of loadZoneDropDown() below: After function execution on console

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