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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:48:51+00:00 2026-06-15T21:48:51+00:00

I have the following array: function theMiddle(){ var arrayTheMiddle = new Array (showName.theMiddle +<br

  • 0

I have the following array:

function theMiddle(){
var arrayTheMiddle = new Array (showName.theMiddle  +"<br />" + beginingTime.theMiddle  +"  <br    />" + network.abc  +"<br />" + duration.thirty  +"<br />" + rating.general  +"<br />" +    description.theMiddle  +"<br />" + showImagetheMiddle);
 document.getElementById("gridbar").innerHTML=(arrayTheMiddle);
 }

The last object in that array, showImagetheMiddle is an image with the following code:

 var showImagetheMiddle = new Image();
 showImagetheMiddle.src = 'abc.jpg';

All my objects appear on my webpage but the showImagetheMiddle gives me the following error:

[object HTMLImageElement]

I’ve looked around but found more complex ways to display an image, I would like to keep it simple and add the image within my existing array (as shown above). Is this possible? If not what am I doing wrong here?

Any help would be most appreciated!

  • 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-15T21:48:52+00:00Added an answer on June 15, 2026 at 9:48 pm

    Since arrayTheMiddle is the array, you need to use the subscript operator [] to get an element from it. In your example, the image is the first (0-th) element in the array. Your line should be this instead:

    document.getElementById("gridbar").innerHTML = arrayTheMiddle[0];
    

    As a side note, it’s much better to create arrays using the square bracket notation [] (not the subscript operator).

    var arrayTheMiddle = [ ... ];
    

    EDIT: After seeing your comment I now recommend you use .appendChild to insert the element into the document. Because simply appending by + won’t work the way you expect. Here is your code:

    var arrayTheMiddle = [showName.theMiddle  +"<br />" + beginingTime.theMiddle  +"  <br    />" + network.abc  +"<br />" + duration.thirty  +"<br />" + rating.general  +"<br />" +    description.theMiddle  +"<br />"];
    
    document.getElementById("gridbar").innerHTML = arrayTheMiddle[0];
    document.getElementById("gridbar").appendChild( showImagetheMiddle );
    

    I found some misconceptions in your code. For example, I don’t think you understand how arrays work. So here is some information:

    Syntax:

    Array elements are created using the square bracket notation []. The elements of an array are separated by the comma operator ,. For instance:

    var l = [ 5, 3, 5, 6 ];
    

    Array elements are separated only by commas. The + operator doesn’t separate them. So here is valid code, but there is only one element in the array:

    var l = [ 5 + 3 + 5 + 6 ];
    

    In your code example, arrays are superfluous. You can very well do what you need without it. So here is your new code:

    function theMiddle() {
        var arrayTheMiddle = ; // the same without '[' and ']'
        document.getElementById("gridbar").innerHTML= arrayTheMiddle;
        document.getElementById("gridbar").appendChild( showImagetheMiddle );
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following function: addBook : function() { _authors = new Array(); authors
I have the following: function quickSort(array, low, high) { var len = array.length, l
I have the following array: var example = [ function() { /* hello */
All, I have the following array and function, which will create a multidimensional array
I have the following code: function build_all_combinations(input_array){ array = [1,2,3] limit = array.length -
I have the following Symfony2 form: public function buildForm(FormBuilder $builder, array $options) { $builder
I have the following code function generate_pdf() { $fdf_data_strings = $this->get_hash_for_pdf(); #$fdf_data_names = array('49a'
I have the following code: <?php function foo($bar) { global $products; //$products = array();
I have the following array: var idParam = [1,2,3]; I want to send this
I have the following (example) array of objects: var theArray = [ {theId:'1', num:

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.