I'm making a comment area where I have multiple posts, the posts are wrapped in a loop where the ID pulls in the correct post, and then below each post is an input area that I am trying to use ajax to post the response. I can get this to alert the correct form id but I can't get the form#"+Form"" to submit.
So I have this in my header,
function send(id){
var PostID = (id);
var Form = ("commentupdate" + PostID + "");
document.Form.submit();
$("form#"+Form+"").submit(function() {
alert(Form);
var action = $('#action').val();
var commentviewedID = $('#commentviewedID').val();
var commentID = $('#commentID').val();
var user = $('#user').val();
var userID = $('#userID').val();
var PostID = $('#PostID').val();
$.ajax({
type: "POST",
url: "include_wall_front/updatecomment_ajax.php",
data: "&action="+ action + "&commentviewedID="+ commentviewedID + "&commentID="+ commentID + "&user="+ user + "&userID="+ userID + "&PostID="+ PostID,
success: function(){
$("ul#wall" + PostID + "").append("<li style=\"display: none;\">a bunch of code</li>");
$("ul#wall" + PostID + " li:first").fadeIn();
}
});
return false;
});
}
which alerts the id if I use (Like commentupdate28) if I am trying to comment to this Post ID
function send(id){
var PostID = (id);
var Form = ("commentupdate" + PostID + "");
}
so I put the var Form in as $("form#"+Form+"").submit(function() {
and this should be correct. Here is my comment area code.
<form method=\"post\" id=\"commentupdate$PostID\" action=\"\">
<input type=\"hidden\" id=\"action\" value=\"commentupdate\" />
<input type=\"hidden\" id=\"commentviewedID\" value=\"$PostUserID\" />
<input type=\"hidden\" id=\"commentID\" value=\"$CommentmainID\" />
<input type=\"hidden\" id=\"user\" value=\"$user\" />
<input type=\"hidden\" id=\"userID\" value=\"$user_ID\" />
<input type=\"hidden\" id=\"PostID\" value=\"$PostID\" />
<input type=\"hidden\" id=\"UserPostID\" value=\"$CommentUserID\" />
<input type=\"text\" class=\"comment-insert\" id=\"$PostID\" name=\"commentinsert\" size=\"100\" onblur=\"send(this.id)\" onFocus=\"clearText(this)\" value=\"Make a comment...\" />
</form>
I had this working when I use the $(document).ready(function(){ instead of the function send(id) but then it only submits to the last $PostID that has been loaded, so I am trying to break out each post and put the comments in each post id so they are all separate.