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

200
Views
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
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!