I am trying to build a website that has a discussion forum using django. I want users to be able to post new comments or reply to other user’s comments. I have it so when they click the reply button, a new text area pops up
HTML
<button onclick="myFunction({{forloop.counter}})">Reply</button>
<div id="{{forloop.counter}}"> </div>
Javascript
function myFunction(x)
{
document.getElementById(x).innerHTML="<form action='' method='post'> {% csrf_token %} <textarea id=reply_body name=reply_body value={{reply_body}}> </textarea> <input type=submit> </form> ";
}
….What I want to do is pass the text of the body to my views so that I can know which comment the reply was to. However, I can’t pass the textbody into the .innerHTML= … Whenever I try to it just says that nothing is there. Is there something I’m missing here? Or an easier way to do this? Any help would be appreciated. Let me know if I should post more code or describe anything in greater detail.
Do you not mean