soneen
06-21-2010, 04:58 PM
Hey guys, I'm trying to make a function that will display certain elements when a paragraph is clicked. As of right now, the function is called, and only the first line gets executed properly. The rest don't work. $postCount is a counter variable setup by a for loop that it is in. When I view source, it is working properly.
function newComment".$postCount."()
{
document.getElementById('postComment$postCount').style.display = 'none';
document.getElementById('newCommentProfilePicture$postCount').style.display = '';
document.getElementById('commentBox$postCount').style.display = '';
document.getElementById('submitComment$postCount').style.display = '';
document.getElementById('addCommentContainer$postCount').style.display = '';
document.getElementById('commentBox$postCount').rows = '3';
}
echo "<div class='viewComment' id='viewCommentButton".$postCount."'>
<div class='leftCommentControl'>";
if ($numComments > 0)
{
echo "<p class='viewCommentLink' id='viewCommentLink".$postCount."' onclick='showComment".$postCount."()'
onmouseover=\"this.style.textDecoration='underline';
this.style.cursor='pointer'\" onmouseout=this.style.textDecoration='none'>
View ".$numComments." Hidden Comments!</p>";
}
echo "</div>
<div class='rightCommentControl'>
<p class='postComment' id='postComment".$postCount."' onclick='newComment".$postCount."()' onmouseover=\"this.style.textDecoration='underline';
this.style.cursor='pointer'\" onmouseout=this.style.textDecoration='none'>Add Comment</p>
</div>
</div>
<div class='addCommentContainer' id='addCommentContainer".$postCount."' style='display: none'>
<form action='processComment.php?userid=".$_SESSION['userid']."&postid=".$row['postid']."&sentFrom=$currentPage' method='POST'>
<img class='newCommentProfilePicture id='newCommentProfilePicture".$postCount."'
src='uploadPic/mini".$_SESSION['picture']."' style='display: none'></img>
<textarea id='commentBox".$postCount."' class='commentTextArea' name='commentBox'
rows='1' cols='49' onfocus='newComment".$postCount."()'></textarea>
<input type='submit' class='button' id='submitComment".$postCount."' name='submit' ALT='Submit button' value='Comment'
style='display: none'>
</form>
</div>
</div>
</div>";
function newComment".$postCount."()
{
document.getElementById('postComment$postCount').style.display = 'none';
document.getElementById('newCommentProfilePicture$postCount').style.display = '';
document.getElementById('commentBox$postCount').style.display = '';
document.getElementById('submitComment$postCount').style.display = '';
document.getElementById('addCommentContainer$postCount').style.display = '';
document.getElementById('commentBox$postCount').rows = '3';
}
echo "<div class='viewComment' id='viewCommentButton".$postCount."'>
<div class='leftCommentControl'>";
if ($numComments > 0)
{
echo "<p class='viewCommentLink' id='viewCommentLink".$postCount."' onclick='showComment".$postCount."()'
onmouseover=\"this.style.textDecoration='underline';
this.style.cursor='pointer'\" onmouseout=this.style.textDecoration='none'>
View ".$numComments." Hidden Comments!</p>";
}
echo "</div>
<div class='rightCommentControl'>
<p class='postComment' id='postComment".$postCount."' onclick='newComment".$postCount."()' onmouseover=\"this.style.textDecoration='underline';
this.style.cursor='pointer'\" onmouseout=this.style.textDecoration='none'>Add Comment</p>
</div>
</div>
<div class='addCommentContainer' id='addCommentContainer".$postCount."' style='display: none'>
<form action='processComment.php?userid=".$_SESSION['userid']."&postid=".$row['postid']."&sentFrom=$currentPage' method='POST'>
<img class='newCommentProfilePicture id='newCommentProfilePicture".$postCount."'
src='uploadPic/mini".$_SESSION['picture']."' style='display: none'></img>
<textarea id='commentBox".$postCount."' class='commentTextArea' name='commentBox'
rows='1' cols='49' onfocus='newComment".$postCount."()'></textarea>
<input type='submit' class='button' id='submitComment".$postCount."' name='submit' ALT='Submit button' value='Comment'
style='display: none'>
</form>
</div>
</div>
</div>";