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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:33:43+00:00 2026-06-10T18:33:43+00:00

In javascript loop i am generating a xml like this: for (m = 0;

  • 0

In javascript loop i am generating a xml like this:

for (m = 0; m < t.length; m++) {
     var arr1 = t[m].split("\t");
     s = "'<row dc= '" + arr1[0] + "' al='" + arr1[1] + "' msg='" + arr1[2] + "' />'";
     alert(s);
     //s = s.join(' '); 
    }

Forgot about the t variable and all. by run this code i am getting the s value in the following format:

<row dc = "abc" al="56" msg="dkaj" />

In the second iteration it shows like this:

<row dc = "abwwc" al="56w" msg="dkajad" />

and so on till the m<t.length satisfy. What i want to join the list in each iteration. After joining all of them i should get in this way:

<row dc = "abc" al="56" msg="dkaj" /><row dc = "abwwc" al="56w" msg="dkajad" /> and so on..

I tried to do it with join written in comment section, but didn’t work for me. What i am doing wrong?

  • 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-10T18:33:45+00:00Added an answer on June 10, 2026 at 6:33 pm

    The best way would be to define a string outside the loop an append to it;

    var v = '';
    for (m = 0; m < t.length; m++) {
         var arr1 = t[m].split("\t");
         s = "'<row dc= '" + arr1[0] + "' al='" + arr1[1] + "' msg='" + arr1[2] + "' />'";
         alert(s);
         v += s;
        }
    
    alert(v);
    

    If you still want to use join(), make v an array and push() elements on to it (note that join() is an array method, not for string’s)

    var y = [];
    for (m = 0; m < t.length; m++) {
         var arr1 = t[m].split("\t");
         s = "'<row dc= '" + arr1[0] + "' al='" + arr1[1] + "' msg='" + arr1[2] + "' />'";
         alert(s);
         y.push(s);
        }
    
    alert(y.join(''));
    

    You’ll be pleased to see I’ve tried to adhere to your variable naming conventions in my examples (i.e. meaningless characters).

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

Sidebar

Related Questions

Objects in javascript throw me for a loop! In this set up... var obj
I have a Javascript For Loop... var CookieName = Tab,EduTab,EduTab,user; var tString = CookieName.split(',');
i am using javascript for loop, to loop through a particular array and alert
I have the following javascript to loop through an array of records, and alert
I want to create a JSON string from a javascript for loop. This is
Consider this JavaScript Code: <script type=text/javascript> function loop(Message){ document.getElementById('output').innerHTML = document.getElementById('output').innerHTML + Message +
Possible Duplicate: Javascript for loop and setTimeout issue I want this loop to change
Javascript loop continue,or break to display? This is my code use for show or
I want to force a repaint during a Javascript loop. For example: var s
I have a javascript loop and want to highlight some numbers for(i=0;i<=100;i++){ $(#mydiv).append(<span>+i+</span>); }

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.