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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:47:29+00:00 2026-05-26T11:47:29+00:00

Ok so this is my dumb problem. im here learning and…ive been looking at

  • 0

Ok so this is my dumb problem. im here learning and…ive been looking at this for a while and i dont understand. i have an array with some values that are fed via an object. like so:

function blogObj(name,date,user_entry){
    this.names = name;
    this.dates = date;
    this.blog_entry = user_entry;

    this.propsComb = this.names + this.dates + this.blog_entry;
}

var blogRun = [
        new blogObj("name ", "something ", "something "),
        new blogObj("name ", "something ", "something "),
        new blogObj("name ", "something ", "something "),
        new blogObj("name ", "something ", "something "),
        new blogObj("name ", "something ", "something "),


];

var i=0;
var mssgs = "";

now when i loop through it like this with this doc.write to test:

function hmm(){
    while(i < blogRun.length){ 
    mssgs = blogRun[i].propsComb + '<br/>';
    document.write(mssgs);

    i++;
    }
}

i get all the values i need which are name something something x5 as per the loop and the values of the array. so essentially it works.

now when i replace the "document.write(mssgs)" with

document.getElementById('showMore').innerHTML = mssgs;

making it this

function hmm(){
    while(i < blogRun.length){ 
    mssgs = blogRun[i].propsComb + '<br/>';
    //document.write(mssgs);
    document.getElementById('showMore').innerHTML = mssgs;
    i++;
    }
}

it only shows me the last value of the array. it doesnt loop for the rest of the arrays values.
all im doing is replacing the .write with getElementById etc..

  • 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-26T11:47:30+00:00Added an answer on May 26, 2026 at 11:47 am

    At each iteration you are overwriting (re-assigning) the innerHtml value of 'showMore'

    use += instead to append (add to) the currently existing contents of 'showMore'

    document.getElementById('showMore').innerHTML += mssgs;
    

    Side Note

    I would also prefer that you use a for loop in this situation as you are looping over a static array where the amount of times you need to iterate is known from the beginning

    ( blogRun.length )

    for ( var i = 0, len = blogRun.length; i < len; i++ ) {
        // .... do your stuff here.
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I feel really dumb for asking this question, but here it goes. I have
I have been stuck here for a good while and seem to nail the
I know this is a dumb question and I guess it must have been
Been working on this dumb problem for two days now. If you can help
Forgive me if this is a dumb beginners problem, but I really don't get
Maybe this is a dumb question, but I have the following behavior in Visual
I know this is a dumb question. For some reason my mind is blank
Apologies if this is a dumb question. In previous ASP.NET projects, I've been using
This is a dumb problem but I can't seem to set the padding on
Possible Duplicate: Integer summing blues, short += short problem I feel dumb that this

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.