Following is the code in which textbox is created
<input type="text" class="enter_comment" value='comments' id='comm<?php echo $row['p_id'];?>'/>
<input type='button' value='enter' class='cbtn' id='<?php echo $row['p_id'];?>'>
And here is the button click code in ajax
.
$(".cbtn").click(
function(e){
alert("here");
var id=$(this).attr('id');
var c="#comm"+id;
var comment = $(c).attr("value");
event.stopImmediatePropagation();
$.post("comments.php",{id:id, comment:comment},function(e){
$('.comment').append(e);
}
);
});
The problem is that when I try to get value of text box , it returns null. Even when I tried to set value through innerHTML, it said : "Cannot set property of null".
Above mentioned code is in AJAX in the same file. And ids of text boxes are set by value in database