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 8012227
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T19:15:57+00:00 2026-06-04T19:15:57+00:00

I am building a prototype for a website and I am using a JavaScript

  • 0

I am building a prototype for a website and I am using a JavaScript code to simulate the autocomplete experience like google has on it’s search bar.

However I have modified the array in the sample list to include an image. The problem occurs when I make a selection.

var customarray=new Array(
    '1 Apple /img src="images/AutoComplete/Apple.png" width="627" height="40" />',
    '2 <img src="images/AutoComplete/Apple.png" width="627" height="40" /> Apple iMac ',
    '3 Apple iPad',
    'Apple iPhone',
    'Apple iPod',
    'Apple iPod Touch ',
    'Apple iPod Nano ',
    'Apple iPod Shuffle ',
    'Apple iPod Classic ',
    'Apple MacBook',
    'Apple MacBook Pro',
    'Apple TV');

array 1 will show correctly in the HTML input field, but if i click it the input field will show: “Apple img src=”images/AutoComplete/Apple.png” width=”627″ height=”40″ ” I only want it to show “Apple”.

The second issue is alignment. If I place the image before the text (as show in array 2) i get a broken image file instead of the image.

Any idea on how to correct these issues? Thank you.

  • 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-06-04T19:16:00+00:00Added an answer on June 4, 2026 at 7:16 pm

    First, I see a typo. customarray[0] should be

    '1 Apple <img src="images/AutoComplete/Apple.png" width="627" height="40" />'
    

    Second, when you are putting this text into the HTML tag, make sure you’re using the innerHTML property. It can be something like this

    <div id="dropdownbox"></div>
    <script type="text/javascript">
        //whatever code you have that executes when a search is done
        //...
    
        var html;
        var div = document.getElementById("dropdownbox");
        div.innerHTML = ""; //clears the results
    
        for (var i=0; i<customarray.length; i++) {
            html += "<div>" + customarray[i] + "</div>";
        }
    
        div.innerHTML = html;
    
        //...
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm building a RoR app for facebook using FBML and the Prototype JavaScript library.
I'm building a prototype search application using CakePHP and I have a search controller
Building a website that has English & Japanese speaking users, with the Japanese users
I'm building a web application (using prototype) that requires the addition of large chunks
I am a Javascript/jQuery/Prototype newcomer and I have a page that has a Prototype
I am building an iPhone audio app using Audio Sessions. Prototype was functioning till
Building a website. When I order my tags like this, LightCycle works but Lightbox
I am building a prototype of a windows phone 7 app using d:DesignData in
Good afternoon, We are building a prototype of a deduper. We are using a
Im building this Digital Signage prototype for a master thesis. Im using WPF and

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.