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

222
Views
How to show in drop down div? javascript html

i have a script which gets the automplete data from api:

<!DOCTYPE html>
<html lang="en">
<head>
 <meta charset="UTF-8">
 <meta http-equiv="X-UA-Compatible" content="IE=edge">
 <meta name="viewport" content="width=device-width, initial-scale=1.0">
 <title>Document</title>
 <script src="https://js.radar.com/v3/radar.min.js"></script>
 </head>
 <body>
 <input name="autocomplete" id="autocomplete" oninput="onclickhandler()">

 <script>
 function onclickhandler() {

  var data = [];
  function getName(data) {
  //console.log(data);
  console.log(data);
  var names = [];
  for (var i = 0; i < data.length; i++) {
     names.push(data[i].formattedAddress);
   }
   console.log(names);
  }

    var text=document.getElementById("autocomplete").value;
    var theUrl="https://api.radar.io/v1/search/autocomplete? 
    query="+text+"&country=IND&limit=5";
     var xmlHttp = new XMLHttpRequest();
     xmlHttp.open( "GET", theUrl, false ); 
     // false for synchronous request



 xmlHttp.setRequestHeader("Authorization","my_api");
xmlHttp.send( null );
//console.log(xmlHttp.responseText);
data = JSON.parse(xmlHttp.responseText);
getName(data);
var count = Object.keys(data).length +1;
 console.log(count);
 for (var i = 0; i <= count; i++) {
  var yourValue = data.addresses[i].formattedAddress;
 console.log(yourValue);
 }


}

</script>

</body>
</html>

which gives the result in console :

Meerut, UP IND Muradnagar, UP IND Muzaffarnagar, UP IND HR IND

what i want is to show a dropdown as shown image linked with input:

enter image description here

and when user select a dropdown it must update the value of input field just same like google maps places autocomplete api.

Thankyou in advance <3;

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!