I am developing an ask-and-answer website. There is a "Choose as best answer" button besides each answer, this button should be visible to the asker but should be invisible to other viewers. Other part of the web page is almost the same. So how can I code this web page? Should I check the viewer identity every time to determine whether or not the button should be visible. If there are many answers to a question, there are many buttons hidden from viewers except the asker. Does this kind of coding waste a lot of extra bandwidth? And I think this kind of coding is a little bit fishy. Is there a better way to do it?
The same problem goes with the "add comment" button. Right below there is an "Add comment" button and a hidden <form><textarea></textarea></form>
, if there are 20 answers, there would be 20 hidden <form></form>
, the hidden code greatly increase the size of the HTML file. Is there an elegant way instead?
As for "add comment" button, any logged user can add comment, so there is no identity differentiation. So how to deal with the issue?