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

  • Home
  • SEARCH
  • 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: $telnums = array(10, 20, 30); $obj = new StdClass(); $obj->telnums
I have following code in the form_Load function System.Windows.Forms.Timer newtimer = new Timer(); newtimer.Tick
I have following code snippet: self.xmlHttpReq = new XMLHttpRequest(); self.xmlHttpReq.onreadystatechange = function() { if(self.xmlHttpReq.readyState
I have following code snippet in c#. var list = new List<string> { a,
I have the following code: $bind = new COM(LDAP://CN=GroupName,OU=Groups,OU=Division,DC=company,DC=local); When I execute it from
I have the following code snippet. $items['A'] = Test; $items['B'] = Test; $items['C'] =
I have the following code: String inputFile = somefile.txt; FileInputStream in = new FileInputStream(inputFile);
I have the following code making a GET request on a URL: $('#searchButton').click(function() {
I have following code in VS2008 If Linq.Enumerable.Contains(Of String)(selectedUsersRoles, RoleCheckBox.Text) Then RoleCheckBox.Checked = True
i have following code for allocation two dimensional array #include <iostream> using namespace std;

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.