0

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.

2
Contributors
1
Reply
3
Views
5 Years
Discussion Span
Last Post by sun-tzu
0

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

First for the HTML: (All untested code!)

<html>
<head>

<!-- 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>

</head>
<body>
<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" />
</form>

<div id="posts">

</div>
</body>

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.

Edited by sun-tzu: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.