许多的第一个表单在点击时提交

Problem: Multiple forms on the same page, but only the first one is being submitted.

Tried the following: Equating the data-ids of submit button and Form inorder to submit the clicked form (No Luck) Dynamic form creation using Javascript.(disbanded that idea after a few tries since it was on a deadline)

Usecase The number of forms depends on the User. If there is just one comment from him, the form submits, while if there are say 4 forms, only the first one will submit.

Javascript:

$(function() {
    $(".submit").click(function() {
        var data_id = $(this).data('id');
        var form_id = $(this.form).data('id');
        if (parseInt(data_id, 10) == parseInt(form_id, 10)) {
            var commentid = document.getElementByID('commentid');
            alert(commentid + formid);
        } else {
            alert("10");
        }
    });
});

PHP code:

if($comment['Comment_Username'] ==$this->getUser()->getName()) 
{$output .='div class="panel" data-class="'.$comment['CommentID'].'">';
$output .='<form class="form" action="" method="post" data-  id="'.$comment['CommentID'].'">';
$output .='<textarea name="edit_text' class="box" rows="2" cols="1">'.$this->getCommentText($comment['Comment_Text']).'</textarea>';
$output .='<input name="commentid" type="hidden" id="commentid" value="'.$comment['CommentID'].'"/>';
$output .='<input type="button' data-id="'.$comment['CommentID'].'" class="submit" value="submit"/>';

Any help would be greatly appreciated. Thanks in advance

Wrong quote used here

$output .='<textarea name="edit_text" class="box" rows="2" cols="1">'.$this->getCommentText($comment['Comment_Text']).'</textarea>';