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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T12:02:05+00:00 2026-06-04T12:02:05+00:00

UPDATE1: Updated the JS fiddle link sorry set interval was not working as I

  • 0

UPDATE1: Updated the JS fiddle link sorry set interval was not working as I wanted it to

I have a array which is dynamically growing (number getting added every 1 sec). I have to split this list and display it in columns, I am actually have problem displaying the list inside the ul and li(yes only ul and li no tables). The user can specify the max number of columns(Stop adding columns once there are this many) and the minimum column height(No added column may contain fewer than this many items). Also, the number of items in any added column must be either the same as, or 1 fewer than for the previous column. The output for max column =3 and min column height =3

enter image description here

What I was able to do so far is:

  1. use set interval to add number every 1 sec

  2. put the incoming numbers in an array like [1] , [1,2] ... [1,2,3,4] after 4 sec. This array is called range

  3. split the main array (range) into sub array (new_range) for eg if the main array

    (range) = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

    new_range (after 1st loop) = [1, 2, 3, 4]

    new_range (after 2nd loop) = [5, 6, 7]

    new_range (after 3rd loop) = [8, 9, 10]

  4. so now I need to display each new range vertically using ul and li so i tried doing something like $('ul').append('<li>' + new_range[j] + '</li>'); were j is the new_range array index

I have problem displaying the li items next to each other like the sample output using CSS, It would be great if someone could tell me how to display the li items after each iteration next to each other

JS fiddle link

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

    I found your fiddle too confusing, so I’ve started from scratch.

    The following function takes an array of values, data, the maximum number of columns, cols, and the maximum size of each column, size. If data has more than cols * size values the leftovers are not shown. It creates columns as individual ul elements, each of which are appended to a container that is presumed to exist with the id “container” (the first thing the function does is empty that container).

    function createList(data, cols, size){
        var $ul,
            $container = $("#container").empty();
    
        $.each(data, function(i,v){
            if (i >= cols * size)
                return false;
            if (i%size === 0)
                $ul = $("<ul/>").appendTo($container);
    
            $ul.append($("<li/>").html(v));
        });
    }   
    

    The ul elements can be shown side by side (i.e., as columns) with this CSS:

    ul { float : left; }
    

    Working demo that adds values to the array using setInterval(): http://jsfiddle.net/VXAHy/1/

    I don’t show any of the setInterval() or array-populating code here in my answer because that is all irrelevant: the above function always redraws all of the columns based on the array passed in. (I do show the interval stuff in my demo fiddle.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have updated my code and made a fiddle which explains what I am
I have a site which uses overlay pages, all was working fine until I
I have a simple fiddle set up that attempts to illustrate this, but essentially
UPDATED TO ADD FIDDLE: http://jsfiddle.net/wvUqy/6/ I have a page_action in Chrome that parses the
UPDATE I have updated my code in response to @MichaelRushton comments. I am now
UPDATED QUESTION Since the ctor is not supported by .NETCF (public FileStream(IntPtr handle, FileAccess
UPDATE If you try the form on this link http://jsfiddle.net/Matt_KP/BwmzQ/ the fiddle and select
See the following fiddle: [edit: updated fiddle => http://jsfiddle.net/NYZf8/5/ ] http://jsfiddle.net/NYZf8/1/ (view in different
I HAVE UPDATED WITH FIDDLES, SEE BOTTOM I am developing a wordpress theme to
I am trying to debug the reason why my ajax get/post is not working

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.