First, I'm new to form and looking forward to all your insight.
My issue: I'm building a small site and I've run into a problem generating unique HTML ids. I'm generating the HTML via a loop in PHP, sent to a smarty template. I admit, my JavaScript abilities are not good which is why I can't figure this out… All I want to is to display the comment form under each article when the "add a Comment" link is clicked.
Here is the JavaScript -
<script>
function show_cform() {
o = document.getElementById("comment_link");
if (o) { o.style.display = ""; }
o = document.getElementById("comment_form");
if (o) { o.style.display = "none"; }
}
</script>
And the HTML that repeats several times -
<div id="comment_form">
<!-- Article Content Here -->
<a href="javascript:show_cform();">Add a Comment</a>
</div>
<div id="comment_link" style="display: none;">
<form method="post" action="blog_comment.php">
<input type="hidden" name="ID" value="{$id}">
Your Name:<br />
<input name="name" type="text" />
<br /><br />
Comment:<br />
<textarea name="comment" rows="8" cols="40"></textarea>
<br /><br />
<input type="submit" value="Post comment">
</form>
</div>
Thanks in advance for the help!