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 716677
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T05:19:35+00:00 2026-05-14T05:19:35+00:00

I’m trying to make a request/reply section in my project. I want to achieve

  • 0

I’m trying to make a request/reply section in my project.
I want to achieve these functionality in that code (that I’m not able to implement; so guys please help me out):
1> When user click on reply button; other reply area(text-area +button) should be hide (means at a time only one reply area should be visible to the user).
2> when user click on reply button text-area will focus and page will slide down (suppose user reply 10 comment focus will automatically set to the 10 number text area and page will slide down to that position accordingly).

Here is my so far code guys:

    //method call on the click of reply link.  
    function linkReply_Clicked(issueId) {    

        Id = issueId;
        textId = "text_" + issueId + count;
        btnReply = "btnReply_" + issueId + count;
        btnCancel = "btnCancel_" + issueId + count;

        var textareasArray = document.getElementsByTagName("textarea");
        var btnArray = document.getElementsByTagName("input");

        for (i = 0; i < textareasArray.length; i++) {
            textareasArray[i].style.display = "none";
            btnArray[i].style.display = "none";
        }

        var str = "<table cellpadding='3' cellspacing='0' width='58%'>";
        str += "<tr><td valign='top' align='left'>";
        str += "<textarea id=" + textId + " rows='5' cols='60'></textarea>";
        str += "</td></tr>";
        str += "<tr><td valign='top' align='right'>";
        str += "<input id=" + btnReply + " type='button' onclick='btnReply_Clicked(Id ,textId)' value='Reply' />&nbsp;";
        str += "<input id=" + btnCancel + " type='button' onclick='btnCancel_Clicked(Id ,textId)' value='Cancel' />&nbsp;";
        str += "</td></tr>";
        str += "</table>";
        document.getElementById("divOuter_" + issueId).innerHTML = str;
        $("#" + textId + "").focus();

    }
    // submit user reply and try to hide that reply area.  
    function btnReply_Clicked(issueId, textID) {

        var comment = document.getElementById(textID).value;
        if (comment != '') {
            $.getJSON("/Issue/SaveComment", { IssueId: issueId, Comment: comment }, null);

            $("#text_" + issueId + count).hide();
            $("#btnReply_" + issueId + count).hide();
            $("#btnCancel_" + issueId + count).hide();
            document.getElementById(textID).value = '';
            count = count + 1;
        }
    }

    // cancel user reply and try to hide that reply area.  
    function btnCancel_Clicked(issueId, textId) {

        $("#text_" + issueId + count).hide();
        $("#btnReply_" + issueId + count).hide();
        $("#btnCancel_" + issueId + count).hide();
        document.getElementById(textId).value = '';
        count = count + 1;
    } 
  • 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-14T05:19:35+00:00Added an answer on May 14, 2026 at 5:19 am

    I changed a bit of this because you can do it much easier since you’re already using jQuery 🙂
    Go here for the demo version

    You can replace all of your posted code with this:

    function linkReply_Clicked(issueId) {
        $(".replyTable").hide();        
        var tbl = $("<table class='replyTable' cellpadding='3' cellspacing='0' width='58%'></table>");
        tbl.append("<tr><td valign='top' align='left'><textarea rows='5' cols='60'></textarea></td></tr>");
        tbl.append("<tr><td valign='top' align='right'><input type='button' class='reply' value='Reply' />&nbsp;<input type='button' class='cancel' value='Cancel' />&nbsp;</td></tr>");
    
        tbl.find(".reply").click(function() {            
            var comment = $(this).closest("table").find("textarea").val();
            if (comment != '') {
                $.getJSON("/Issue/SaveComment", { IssueId: issueId, Comment: comment }, null);
                $(this).closest("div").empty();
            }
        }).siblings(".cancel").click(function() {
            $(this).closest("div").empty();
        });
    
        var div = $("#divOuter_" + issueId).empty().append(tbl);
        $('html, body').animate({ scrollTop: $(div).offset().top }, 500,
                                function() { div.find("textarea").focus(); });
    }
    

    This does the following things differently with the slide effect & the hiding and scrolling from the question:

    • Click handlers for reply/cancel buttons are now in-line, no need for extra functions
    • The inputs no longer have IDs you need to track, it just finds them relatively
    • Table has a class replyTable so it all old ones can be hidden quickly
    • Inputs have classes to find them easier (to bind the click handlers)
    • No more count, no need 🙂
    • Animates the body, does a quick scroll effect to the location and focuses the text area
    • Removes old tables to cleanup
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function

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.