Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

193
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda