0
私はスタックオーバーフロースタイルのコメントシステムを持っています。ここでは、人がコメントできるページに可変数のポスト(「回答」)があります。私はjqueryを使用して、ユーザコメントのユニークなセレクタをつかみ、それをmysqlデータベースに提出し、それを表示することを試みています。問題は、個々のコメントを選択する方法がわからないことです。コメントには一意のセレクタが必要で、今はすべてが同じクラス(.commentBox)の下にあるからです。複数のポストコメントシステム
のjQuery:
<script type='text/javascript'>
$('document').ready(function(){
$('.submitCommentBox').click(function(){
var comment = $(' //idk ').valu();
var questionid = $(' //idk ').val();
var answerid=$(' //idk ').val();
$.post('../comment.php',
{
comment: comment,
questionid: questionid,
answerid: answerid,
},
function(response){
$('#commentContainer').load('../writecomment.php');
});
}):
});
</script>
HTML(これは、whileループ内にあり、投稿数に応じて複数回エコー表示):
<div class='answerContainer'>
<p name='singleAnswer' value='$answerid[$f]'>$answer[$f]</p>
<p>$answeruser[$f]</p>
<p> $time[$f] seconds</p>
<p> $answerrating[$f]</p>
<form id='form$c'>
<div id='commentContainer'></div>
<textarea class='commentBox' placeholder='...comment' wrap='soft' name='comment' value='$c'></textarea>
<input type='button' value='submit' class='submitCommentBox'>
</form>
</div>