I want to enhance my FAQ by making it easily editable. Currently, the content can only be edited in the HTML file. I am looking to load all the information from a JSON file so that any changes or additions to questions and answers can be made directly in the JSON file. While I attempted to create a CRUD functionality for this purpose, it proved to be quite challenging for me. If anyone knows how to implement a CRUD system and is willing to explain it or provide a tutorial (where data is still loaded into HTML elements), I would greatly appreciate it.
On another note, I am trying to embed JSON objects in HTML elements. The <H2>
tag will hold the category, while the question goes inside the <a></a>
tags and the answer within <p></p>
tags. Can someone guide me on the JavaScript code required for this task? My goal is to check the category and automatically populate all questions related to that category from the JSON file in their respective places. Despite multiple attempts and research efforts, I have been unable to find a solution. Thank you in advance for your help.
JSON:
{
"question": [
{
"id": 1,
"question": "Quest",
"answer": "Ans",
"category": "Cat"
},
{
"id": 2,
"question": "Quest2",
"answer": "Ans2",
"category": "Cat2"
},
{
"id": 3,
"question": "Quest2",
"answer": "Ans2",
"category": "Cat2"
},
{
"id": 4,
"question": "Quest2",
"answer": "Ans2",
"category": "Cat2"
}
]
}
HTML:
<ul id="algemeen" class="cd-faq-group">
<li class="cd-faq-title"><h2>General</h2></li>
<li>
<a class="cd-faq-trigger" href="#0">Question</a>
<div class="cd-faq-content">
<p>Answer</p>
</div>
</li>