I have the following javascript file
let objUno = {
Traumatologia: [
{
HORA: "8:00",
ESPECIALISTA: "MARIA PAZ ALTUZARRA",
PACIENTE: "PAULA SANCHEZ",
RUT: "15554774-5",
PREVISION: "FONASA"
},
{
HORA: "10:00",
ESPECIALISTA: "RAUL ARAYA",
PACIENTE: "ANGÉLICA NAVAS",
RUT: "15444147-9",
PREVISION: "ISAPRE"
},
{
HORA: "10:30",
ESPECIALISTA: "MARIA ARRIAGADA",
PACIENTE: "ANA KLAPP",
RUT: "17879423-9",
PREVISION: "ISAPRE"
},
{
HORA: "11:00",
ESPECIALISTA: "ALEJANDRO BADILLA",
PACIENTE: "FELIPE MARDONES",
RUT: "1547423-6",
PREVISION: "ISAPRE"
},
{
HORA: "11:30",
ESPECIALISTA: "CECILIA BUDNIK",
PACIENTE: "DIEGO MARRE",
RUT: "16554741-K",
PREVISION: "FONASA"
},
{
HORA: "12:00",
ESPECIALISTA: "ARTURO CAVAGNARO",
PACIENTE: "CECILIA MENDEZ",
RUT: "9747535-8",
PREVISION: "ISAPRE"
},
{
HORA: "12:30",
ESPECIALISTA: "ANDRES KANACRI",
PACIENTE: "MARCIAL SUAZO",
RUT: "11254785-5",
PREVISION: "ISAPRE"
}
],
}
let clientesUno = objUno.Traumatologia;
for(item of clientesUno){
let textUno = `<p>${item.HORA}, ${item.ESPECIALISTA}, ${item.PACIENTE}</p>`
document.getElementById("traumatologia").innerHTML+=textUno;
}
let obj = {
Radiologia: [
{
HORA: "11:00",
ESPECIALISTA: "IGNACIO SCHULZ",
PACIENTE: "FRANCISCA ROJAS",
RUT: "9878782-1",
PREVISION: "FONASA"
},
{
HORA: "11:30",
ESPECIALISTA: "FEDERICO SUBERCASEAUX",
PACIENTE: "PAMELA ESTRADA",
RUT: "15345241-3",
PREVISION: "ISAPRE"
},
{
HORA: "15:00",
ESPECIALISTA: "FERNANDO WURTHZ",
PACIENTE: "ARMANDO LUNA",
RUT: "16445345-9",
PREVISION: "ISAPRE"
},
{
HORA: "15:30",
ESPECIALISTA: "ANA MARIA GODOY",
PACIENTE: "MANUEL GODOY",
RUT: "17666419-0",
PREVISION: "FONASA"
},
{
HORA: "16:00",
ESPECIALISTA: "PATRICIA SUAZO",
PACIENTE: "RAMON ULLOA",
RUT: "14989389-K",
PREVISION: "FONASA"
}
],
}
let clientesDos = obj.Radiologia;
for(item of clientesDos){
let textDos = `<p>${item.HORA}, ${item.ESPECIALISTA}, ${item.PACIENTE}</p>`
document.getElementById("radiologia").innerHTML+=textDos;
}
let objDos = {
Dental: [
{
HORA: "8:30",
ESPECIALISTA: "ANDREA ZUÑIGA",
PACIENTE: "MARCELA RETAMAL",
RUT: "11123425-6",
PREVISION: "ISAPRE"
},
{
HORA: "11:00",
ESPECIALISTA: "MARIA PIA ZAÑARTU",
PACIENTE: "ANGEL MUÑOZ",
RUT: "9878789-2",
PREVISION: "ISAPRE"
},
{
HORA: "11:30",
ESPECIALISTA: "SCARLETT WITTING",
PACIENTE: "MARIO KAST",
RUT: "7998789-5",
PREVISION: "FONASA"
},
{
HORA: "13:00",
ESPECIALISTA: "FRANCISCO VON TEUBER",
PACIENTE: "KARIN FERNANDEZ",
RUT: "18887662-K",
PREVISION: "FONASA"
},
{
HORA: "13:30",
ESPECIALISTA: "EDUARDO VIÑUELA",
PACIENTE: "HUGO SANCHEZ",
RUT: "17665461-4",
PREVISION: "FONASA"
},
{
HORA: "14:00",
ESPECIALISTA: "RAQUEL VILLASECA",
PACIENTE: "ANA SEPULVEDA",
RUT: "14441281-0",
PREVISION: "ISAPRE"
}
]
}
let clientes = objDos.Dental;
for(item of clientes){
let text = `<p>${item.HORA}, ${item.ESPECIALISTA}, ${item.PACIENTE}</p>`
document.getElementById("consultantes").innerHTML+=text;
}
Render perfectly. What I need is to separate the radiology data by a paragraph, then by another paragraph the traumatology data and then by a paragraph these from the latest data that is printed on the web page. The idea is that I have three arrays made up of objects, I go through them with the code I have and extract certain information. What I need is to separate the groups by a paragraph, that is, the traumatology patients are separated by a paragraph from the radiology patients and these in turn by a paragraph from the dental patients. Enter the code document.write(
) but it deletes the other information. I also tried adding document.getElementsByClassName(".trauma").innerHTML=with the respective class in the html document, but it didn't work. So I want to see what code can be used for this case.
Again, a pleasure to help you with your code, this time you have more than one object, but since all the objects are about medical consultations of different specialties, why not put them all in the same object, so that each property is a specialty name and its content queries? In this way you will have a single object to iterate to, this also makes it easier to make a line break between queries, the code would look like this: