Я бы сделал что-то вроде этого ( ИСПРАВЛЕНО ):
<script>
function show_cform(formDiv) {
// We pass the container into the function, so we can work out the rest
var parts, idNum;
// Get the number from the id
parts = formDiv.id.split('_');
idNum = parts[parts.length -1];
// Change the display of the elements
formDiv.style.display = "none";
document.getElementById("comment_link_"+idNum).style.display = "block";
}
</script>
... и ...
<?php
// Presumably you are generating this in a loop. I don't know how
// your loop currently works, but you just need an incrementing
// id that is unique to each iteration, and put it onto the end
// of the id's of the elements
// For example
for ($i = 0; ($someCondition); $i++) {
?>
<div id="comment_form_<?php echo $i; ?>">
<!-- Article Content Here -->
<a href="javascript:show_cform(this.parentNode);">Add a Comment</a>
</div>
<div id="comment_link_<?php echo $i; ?>" style="display: none;">
<!-- etc etc -->
<?php } ?>
На самом деле, это совсем не то, что я буду делать, но я буду работать с тем, что у вас есть. У меня нет времени, чтобы объяснить, как именно я справлюсь с этим в данный момент, но я могу отредактировать этот ответ, когда у меня нет плачущего ребенка, с которым нужно иметь дело ...