I have this HTML: How do I make a loop that takes the inner text of every p tag and puts it into the data-item attribute of its respective div parent like this: Answer Loop over the divs. In each div, use querySelector() to find the nested p, get its contents with .textContent, and assign that to the div’s data-item
Tag: json
Using Ajax GET to download compressed JSON files
Background. I’m tasked with debugging some PHP and JavaScript code designed to pull static, gzip’ed JSON files from the host server, and manipulate the resulting JSON object’s parameters. Apologies in advance for my misuse of terminology. I have some experience with software development, but very little with web/server development (and almost none with PHP/JavaScript). Code. To “pull” the .json.gz file
Group GeoJson features by property value in JavaScript
I have a list of geojson features that each have an asset ID in their properties. I want to manipulate the geojson so I am left with only a single feature per asset ID, with the properties from each feature found added to the feature properties. As an example, the following geojson has 4 features; 2 of them have an
JSON parsing in React JS for side menu
I have a following JSON Structure which I need to parse in React to build a side menu for an app. The output needed for the nested side menu should be as follows – Is there a simple way using array.map function to achieve this since I am building this menu inside an HTML div. Answer You can create it
Hidden password only works in one input box
I have this JS code that shows 2 input boxes that asks for a password: 1) Password 2) Confirm Password. However, the clickShowPassword() is only connected to Password. [Output] [1]: https://i.stack.imgur.com/IZoa3.png Here’s my whole js file that is connected to an react application. Answer In your second input you used passwordConf as an input type, I think this happened because
Efficient way to merge two array of objects in javascript based on similarities?
So I have two array of objects: and the expected result is: This is just two examples out of thousands of data, I have tried mapping through two arrays and inserting them manually however this would always result in a timeout since I think looping is quite heavy on the backend server. Is there an efficient way to do such
How to nest JSON inside “data:”{} object for POST fetch request?
Long time listener, first time caller. I’ve created a form and sending a fetch request to my database (Xano). My JSON object looks like the below snippet. But Xano needs it to be one level deeper inside “data”, otherwise I can’t map things up with dot notation… My JS is below. So where and how can I make the JSON
SyntaxError: /home/container/config.json: Unexpected token } in JSON at position 2769
Im getting this SyntaxError: /home/container/config.json: Unexpected token } in JSON at position 2769 error, here’s my config.json Can someone please help me fix this I am pretty sure I am supposed to add a : but i dont know how to fix this syntax error I dont understand what is wrong, using node v16 Answer You can use any online
How to update large JSON objects? [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 4 months ago. Improve this question The server sends me a data as JSON to descripe a product. A product consists of properties and nested arrays of properties, up to 4
Cannot read properties of undefined (reading ‘0’) – ( empty error JSON response with postman)
so i’m working with Joi for validation, and i’ve encountered this error when trying to post with postman. i’m follwing a tutorial, i tried to write it differently, but still have the same issue. i’m trying to access the error message. ( first selecting the error, then the details, then the message ) in the tutorial, it looks like this