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

  • Home
  • SEARCH
  • 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 6062049
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:00:25+00:00 2026-05-23T09:00:25+00:00

If you take a look on this post, you will see that there is

  • 0

If you take a look on this post, you will see that there is a “add comment” link below it. When I click on it, a textarea will be added and allow user to write comment.

I am wondering how I can write a similar function?

Updated

Thank you everyone for your help.

I made a working code. However, if it is running with Google Chrome, I will get a terrible lag. I have to wait about 15 seconds to get the textarea out.

But if I run it with IE, then no problem at all… That is a very strange issue.

Here is my code for the JavaScript function

function testCall(id) {

var divName = "#Post-Number-" + id;

var appenedDiv = "<div class='container2' id='r1'>";
appenedDiv+="<div class='acc_container'>";
appenedDiv+=" <div class='block'>";
appenedDiv += "<form method='post' action='' id='loginForm' name='loginForm'>";
appenedDiv+="<p>My Reply:</p>";
appenedDiv+="<p>";
appenedDiv += "<textarea id='test' name='txtReply' cols='8' rows='10'></textarea>";
appenedDiv += id;
appenedDiv+="</p>";
appenedDiv+="<p>";
//appenedDiv+="<%= Html.ActionLink('Submit Reply', 'Login', 'User', new { returnUrl = Request.Url }, new { @class = 'linkButton' })%>";
appenedDiv+="</p>";
appenedDiv+="</form>";
appenedDiv+="</div>";
appenedDiv+="</div>";
appenedDiv += "</div>";

$(divName).after(appenedDiv);
$('html, body').animate({ scrollTop: $('#r1').offset().top }, 100);
//$('#test').focus();

}

Here is how I call this function

<a href="#" onclick="testCall(<%:item.QAID %>);">Test</a>
  • 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-23T09:00:26+00:00Added an answer on May 23, 2026 at 9:00 am

    Simple example: http://jsfiddle.net/zBUgZ/

    <a onclick="addComment(this)">add comment</a>
    
    function addComment(el){
        var t = document.createElement('textarea');
        document.body.appendChild(t);
        el.style.display = 'none';
    }
    

    Using jQuery: http://jsfiddle.net/zBUgZ/1/

    <a class="addcomment">add comment</a>
    
    $('.addcomment').click(function(){
        $(this).after('<textarea class="comment"></textarea>').hide();
    });
    

    EDIT

    Since it’s more likely that the ANCHOR will have a HREF attribute, you should also return false:

    <a class="addcomment" href="http://somelink.somewhere.com">add comment</a>
    
    $('.addcomment').click(function(){
        $(this).after('<textarea class="comment"></textarea>').hide();
        return false;
    });
    

    And if you want to set an ID on the TEXTAREA, you might use one based on the ANCHOR:

    <a id="addcomment1" class="addcomment" href="http://somelink.somewhere.com">add comment</a>
    
    $('.addcomment').click(function(){
        $(this).after('<textarea class="comment" id="'+this.id+'-textarea"></textarea>').hide();
        return false;
    });
    

    http://jsfiddle.net/zBUgZ/2/

    EDIT 2

    And, noting that you’re trying to focus on the element, you can do this if you add an ID to the TEXTAREA:

    Plain Javascript:

    document.getElementById(this.id+'-textarea').focus();
    

    jQuery:

    $('#'+this.id+'-textarea').trigger('focus');
    

    http://jsfiddle.net/zBUgZ/4/

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

Sidebar

Related Questions

take a look at this example code: public class Comment { private Comment() {
This is a follow-up question to this one . Take a look at these
I recently had to take a quick look at Adobe InDesign server. In this
Take a look at the ssl_requirement plugin. Shouldn't it check to see if you're
Please take a look at the html listed below and let me know why
Where would i go to look for algorithms that take a 2d grid of
I trying to put together an Android app that will take a picture and
Please take a look at this site as a reference: http://www.philsalesses.com/place-pulse/ On the left
I was wondering if anyone could take a look at this code and help
Take a look at this awesome code from John P Bloch. What this code

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.