Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7048473
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:53:47+00:00 2026-05-28T02:53:47+00:00

I have a stackoverflow style comment system where there are a variable number of

  • 0

I have a stackoverflow style comment system where there are a variable number of posts (“answers”) on a page that people can comment on. I am trying to use jquery to grab a unique selector of a users comment, submit it into a mysql database and display it, all without refreshing. The trouble is that i don’t know how to select an individual comment, because the comment’s need to have a unique selector and right now they are all under the same class (.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 (this is in a while loop and echos multiple times depending on number of posts):

                 <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>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T02:53:48+00:00Added an answer on May 28, 2026 at 2:53 am

    Instead of the wire up on the submit you can do it on the form and just change the submit button to type=”submit”.

    $('.addCommentForm').submit(function(){
        $.post({
            type: 'POST',
            url: '../comment.php',
            data: $(this).serialize(),   // $(this) referring to the source form that triggered the submit.
            success: function(data, textStatus, jqXHR) {
                // Do whatever like add the display only equivalent of the comment
                // that was just submitted if successful.
            }
        });
        return false; // Prevent the form from actually submitting the old fashion way.
    });
    

    I’d refer to the jquery api for this for more details. http://api.jquery.com/jQuery.post/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have seen many answers on stackoverflow, but I didn't find an answer that
What is the best way to implement a StackOverflow-style Recent Activities page? I have
I have seen stackoverflow ask question page they disable button until my postback event
i need to put the page no like stackoverflow have at the tags page
First, why I ask: Now that reputation points on StackOverflow have real value (you
Hello StackOverflow'ers, I have a (flex) app that, on the click of a button,
Hello StackOverflow community, I have run into a problem that quite frankly is baffling
I have a parent div gal1 , inside which there can be further divs
I have seen it written in multiple threads/comments on stackoverflow that using switch is
So, the web, and StackOverflow, have plenty of nice answers for how to bind

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.