Comment / Reply function
| From: | Merlin | Date: | Thu, 25 Oct 2007 17:26:56 +0000 |
| Subject: | Comment / Reply function | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-263668@lists.php.net to get a copy of this message | ||
Hi there,
I am trying to add a comment functionality to my PHP webapp that includes a reply possibility on each comment. Like on digg for example. I am new to AJAX, but would like to take this oportunity and to jump into cold water with that task now.
I am asking this question here in the PHP forum, as I was thinking to do a for loop to include a form underneath each comment, but now it sounds rediculous to me. There must be a smarter way to do this.
My goal is to use JQuery to show and hide a dialog box which contains the form to reply on the comments.
Basicaly I managed to do this, but now I have a general understanding problem. Let's say there are 100 comments there and I want to have reply possiblity for each of them. Do I have to integrate the same code underneath each one? I would rather like to have a box in that is used for everyone of them. I believe this is somehow done with divs, but I do not know how.
Here is my code:
<html>
<head>
<script src="/app_global/jquery-1.2.1.pack.js" type="text/javascript"></script>
<script type="text/javascript">$(document).ready(function() { $('#slickbox').hide(); $('a#reply').click(function() { $('#slickbox').toggle('slow'); return false; }); });
</script></head> <body> <a href="#" id="reply">Reply</a> <div id="slickbox"><p>Space for reply box</div> <p> next comment </body> </html> I would like to place a complex reply form into the id=slickbox, but here is where the problems starts. If I do this for all 100 comments the code will be way to much to load. Even if it is easy to do with PHP. There must be a smarter way to achieve this. Thank you for any help on this. I am pretty much stuck here. Best regards, Merlin