I want to know that how i can get the text which user write in text area and want to show that text in web page same as facebook when we write something and and add comment it will show in a div how i can go with innerHTML

i can get the value like document.getElementById("commentBox").value;

but how i show in a div like facebook

waiting for your reply.

Fairly easy to do surprisingly. As long as you have enough PHP or other server side experience.

First for the HTML: (All untested code!)


<!-- Make sure to include jQuery -->
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.js"></script>

<script type="text/javascript" src="/js/status-update.js"></script>

<title>Status Update Test</title>

<form id="status-update" method="post" action="/">
<textarea name="status" id="status" rows="5" cols="50"><br />
<input type="button" id="submit-status" value="Post" />

<div id="posts">


Make sure you have included jQuery between the two "head" tags:

Now for the jQuery:

// status-update.js

     $(document).ready(function() {

          $("#submit-status").click(function() {

               // If the form is empty do nothing
               if ($("textarea#status").val() != '') {

                    $("textarea#status").css({ 'opacity':'.5' });

                    $.post('your-callback.php',$("#status-update").serialize(),function(data) {

                         $("#posts").prepend('<div id="status-container">' + content + "</div>");

                         $("textarea#status").val('').css({ 'opacity':'1' });





The coding of the callback page is up to you, but you get the jist of it I hope.