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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:30:03+00:00 2026-05-23T01:30:03+00:00

I have the following code – <script type=text/javascript> function test() { var results =

  • 0

I have the following code –

    <script type="text/javascript">
function test() {
    var results = "";
    var myArray    = new Array();
    myArray[0] = "Customizable";
    myArray[1] = "Marketing Collateral";
    myArray[2] = "Online Marketing";
    myArray[3] = "Training";
    myArray[4] = "Event Resources";
    myArray[5] = "Marketing Logos";
    myArray[6] = "Competitive Solution Comparison";
    myArray[7] = "Sales Tools";
    myArray[8] = "Retail Marketing"
    myArray[9] = "Internal";        

    results = "<table>";
for (var i=0; i<myArray.length; i++) {
    results += "<tr><td>" + myArray[i] + "</td>";  
    results += "<td>" + myArray[i+1] + "</td></tr>";  
}

results += "<tr><td colspan=2><a href='#' onclick='javascript:RedirectParentToDownload();'>View all content ></a></td></tr>";
results += "<table><br /> <br />";

 var div = document.getElementById("associatedAssets");
    div.innerHTML = results;    
}
</script>
<body onload="javascript:test();">
<div id="associatedAssets"></div>


 </body>

How do I get the output to be rendered as 2 columns and n rows? I want the output to look something like this –

    Customizable      Marketing Collateral
    Online Marketing  Training
    Event Resources   Marketing Logos
    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-23T01:30:04+00:00Added an answer on May 23, 2026 at 1:30 am

    You need to use an increment of 2 for i in your for loop.
    Also add a check to see if the i+1th element exists before using it while concatenating the array content to HTML string.

    Try this:

        function test() {
            var results = "";
            var myArray    = new Array();
            myArray[0] = "Customizable";
            myArray[1] = "Marketing Collateral";
            myArray[2] = "Online Marketing";
            myArray[3] = "Training";
            myArray[4] = "Event Resources";
            myArray[5] = "Marketing Logos";
            myArray[6] = "Competitive Solution Comparison";
            myArray[7] = "Sales Tools";
            myArray[8] = "Retail Marketing"
            myArray[9] = "Internal";        
    
            results = "<table>";
                for (var i=0; i<myArray.length; i=i+2) { //###NOTICE THE CHANGE FROM i++ TO     i=i+2               
                    results += "<tr><td>" + myArray[i] + "</td>";  
                    if(i+1 < myArray.length){
                                    results += "<td>" + myArray[i+1] + "</td></tr>";  
                    } else{
                                 results += "<td></td></tr>";   
                    }
                }
    
            results += "<tr><td colspan=2><a href='#' onclick='javascript:RedirectParentToDownload();'>View all content ></a></td></tr>";
            results += "<table><br /> <br />";
    
             var div = document.getElementById("associatedAssets");
            div.innerHTML = results;    
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following code in VS2008 If Linq.Enumerable.Contains(Of String)(selectedUsersRoles, RoleCheckBox.Text) Then RoleCheckBox.Checked = True
I Have following code: Controller: public ActionResult Step1() { return View(); } [AcceptVerbs(HttpVerbs.Post)] public
I have following Code Block Which I tried to optimize in the Optimized section
I have following code in html: <div> <div style=float:left;margin:0.5em> <span class=title>Label1</span><br/> <input type=text name=name1
I have following code import sys from ctypes import * from ctypes.util import find_library
I have following code: Tools::Logger.Log(string(GetLastError()), Error); GetLastError() returns a DWORD a numeric value, but
I have following code in page load Protected Sub Page_Load(ByVal sender As Object, ByVal
I have following code in my Application. tmp=[[UILabel alloc] initWithFrame:label1Frame]; tmp.tag=1; tmp.textColor=[UIColor blackColor]; [tmp
I have following code in my application: // to set tip - photo in
I am currently running into a problem where an element is coming back from

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.