Friday 23 March 2018

How to position a reply to a comment depending if they share the same ID

I am using NodeJS, Express, MySQL and EJS.I have a 'posts' and a 'comments' table.The comments table has: ID, comment, ReplyToCommentID columns. If replyToID is a number, it means that it's a reply to the comment with that ID, if it's NULL, it means it's a regular comment.The problem: How do I display the replies to the comment with the same ID (or div value) as the ReplyToCommentID?I need something like:Creates the container div(which contains the div of the comment and possibly the replies) Creates the comment div Checks all the reply id's to see if the just made comment div's id is == with any of the reply id if true, create the div of the reply I imagine it would look like this:

Comment Here

<% if(the div's id above is == with some ReplyToCommentID){ %>

Reply here which has the same ReplyToCommentID value as the comment div

<% } %>
Trying to use document.querySelector in a <%= or <% - %> or script tag results in an error.

Submitted March 23, 2018 at 05:24PM by khazha88

No comments:

Post a Comment