Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

190
Views
Javascript: records to be displayed in new line when there are more than one record

Please help me with this.

This is my code to get role, first name and last name from a database. If there are more than one record, the results should get printed in a new line. I tried adding '\n' and <br> tags to get the data to a new line but it didn't work. I tried for loop but it pulls the records more than once and I get duplicate values as below.

ObjAssociatedPartyLocal_tab = variable for first name and last name
ObjAssociatedPartyRole_tab = variable for the role of that person

The result I'm getting is

testrole1 : Test_Last, Test_First testrole1 : testlast2, testfirst2 testrole2 : Test_Last, Test_First testrole2 : testlast2, testfirst2

However, it should be displayed like this,

testrole1 : Test_Last, Test_First,
testrole2 : testlast2, testfirst2

The code I wrote is,

maker = "";             
for(var i=0; i < data.ObjAssociatedPartyRole_tab.length; i++)               
{                   
  if (data.ObjAssociatedPartyLocal_tab !== null && 
  data.ObjAssociatedPartyLocal_tab !== ''){                     
    for(var j=0; j < data.ObjAssociatedPartyRole_tab.length; j++){                              
    maker += data.ObjAssociatedPartyRole_tab[i] + " : " + data.ObjAssociatedPartyLocal_tab[j] + "\n";                       
    }                           
  }                 
}
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!