Answer the question
In order to leave comments, you need to log in
How to pass object from js file to html page?
Good afternoon. I have a somewhat complicated problem, I will try to describe as clearly as possible.
So, I get two objects from the server for my two models. These objects contain category fields, last names, model element identifiers, and so on. By filtering, I get 4 arrays. The first and second arrays store unique identifiers, while the third and fourth arrays store duplicate identifiers. The first array contains a unique identifier for the first model. in the second - unique for the second array, and in the third and fourth - common elements for them, respectively.
To illustrate this, I will give the following example.
const dataFirstModel = [{"revitid": "1"},{"revitid": "2"},{"revitid": "3"},{"revitid": "4"}];
const dataSecondModel = [{"revitid": "1"},{"revitid": "2"},{"revitid": "5"},{"revitid": "6"}];
[ //first array(difference)
{
revitid: 3
building: ""
level: ""
room: ""
viewid: 3302
category: "Walls"
family: "Basic Wall"
symbol: "Wall-Ext_102"
},{
revitid: 4
building: ""
level: ""
room: ""
viewid: 3303
category: "Walls"
family: "Basic Wall"
symbol: "Wall-Ext_102"
}
];
[ //second array(difference)
{
revitid: 5
building: ""
level: ""
room: ""
viewid: 3304
category: "Walls"
family: "Basic Wall"
symbol: "Wall-Ext_102"
},{
revitid: 6
building: ""
level: ""
room: ""
viewid: 3305
category: "Walls"
family: "Basic Wall"
symbol: "Wall-Ext_102"
}
];
[ //first array(similar)
{
revitid: 1
building: ""
level: ""
room: ""
viewid: 3300
category: "Walls"
family: "Basic Wall"
symbol: "Wall-Ext_102"
},{
revitid: 2
building: ""
level: ""
room: ""
viewid: 3301
category: "Walls"
family: "Basic Wall"
symbol: "Wall-Ext_102"
}
];
[ //second array(similar)
{
revitid: 1
building: ""
level: ""
room: ""
viewid: 3300
category: "Walls"
family: "Basic Wall"
symbol: "Wall-Ext_102"
},{
revitid: 2
building: ""
level: ""
room: ""
viewid: 3301
category: "Walls"
family: "Basic Wall"
symbol: "Wall-Ext_102"
}
];
Answer the question
In order to leave comments, you need to log in
- Start by creating the desired element: document.createElement('elemTag')
- Give it classes or attributes: elem.classList.add('someClass')
or document.createAttribute("someAttr")
- Insert it into the page itself parentElem.appendChild(elem)
If anything, it 's described in more detail here
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question