I designed a comment section with a reply. I want a comment form to be created under the same comment when the user clicks on the reply button. I wrote this myself, but when I click on the reply button, the form is created only for the first comment.
function addtextbox() {
// Create a form dynamically.
var form = document.createElement("form");
form.setAttribute("method", "post");
form.setAttribute("action", "submit.php");
// Create an input element for replyText.
var ID = document.createElement("input");
ID.setAttribute("type", "text");
ID.setAttribute("name", "body");
ID.setAttribute("placeholder", "Your Comment");
form.append(ID);
document.getElementsByClassName('formbox')[0].appendChild(form);
}
<button onclick="addtextbox()">reply</button>
<div class="formbox"></div>