Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6182357
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:11:08+00:00 2026-05-24T01:11:08+00:00

I have a script which allows to retrieve Google suggestions (XML) with Javascript and

  • 0

I have a script which allows to retrieve Google suggestions (XML) with Javascript and output in plain HTML:

<input  id='inp' /> <select  id='sug' />

<script type='text/javascript'>

function el(tid) {return document.getElementById(tid);}

function addScript(u){ 
   var head=document.getElementsByTagName('head')[0],
     sc2=document.createElement('script'); sc2.src=u;    
   head.appendChild(sc2);
   setTimeout(function(){ head.removeChild(sc2); sc2=null;}, 20000)
 }//end addScript()


function suggest(data){ 
  var sel=el("sug").options; sel.length=0;
  data[1].map(function(a){return a[0];}).map(function(a,b){
  sel[b]=new Option(a);
 });
 sel.size=data[1].length;
}//end suggeest()


el("inp").onkeyup=function(){
  addScript("http://www.google.nl/complete/search?callback=suggest&q="+this.value);
}

As you can see the XML data is now a select option list. My question: How can I get this in a ul—>li HTML rather than the select option list.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T01:11:09+00:00Added an answer on May 24, 2026 at 1:11 am

    AFAIK there is no standard DOM object to represent ul / li so your “OO” way isn’t working… however, following seems to work in my FireFox browser: in the html body have a list like

    <ul id='test'>
      <li>test</li>
    </ul>
    

    and replace in JavaScript the suggest function with this one

    function suggest(data){ 
      var sel=el("test"); sel.innerHTML='';
      data[1].map(function(a){return a[0];}).map(function(a,b){
      sel.innerHTML += '<li>'+a+'</li>';
     });
    }
    

    BTW add the list before the select element or write it like

    <select  id='sug'></select>
    <ul id='test'>
      <li>test</li>
    </ul>
    

    (ie select is writen with proper end tag) otherwise the list won’t show in the page

    EDIT:
    Version which seems to work in IE

    function suggest(data){ 
      var sel=el("test"); sel.innerHTML='';
      for(x=0; x<data[1].length;x++){
         sel.innerHTML += '<li>'+data[1][x][0]+'</li>';
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a cgi script which takes form input, I want to facilitate the
I have a script which allows me to lookup for a hostname after inputting
I have a system which allows users to enter HTML-reserved characters into a text
I currently have 2 JavaScript variables in which I need to retrieve values from.
I have a script which allows to execute Bash processes in the background, i
I have written a PHP script which allows me to modify and update a
I am currently looking for a JavaScript (jQuery) SlideShow Script which allows me to
I have a script which contacts a few sources and tell them the IP-address
I have a script which logs on to a remote server and tries to
I have a script which will be run interactively by non-technical users. The script

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.