Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa HTML How can I output text typed in textarea by user on the same page?

Have Programming Question? Ask it here!
 
 
 


Colin Lansdown
How can I output text typed in textarea by user on the same page?
2 Answer(s)      3 years ago
Posted in : HTML


I have a basic HTML page where I have created a textarea for users comments. I would like to take the comments and append them to the same page for all to see. Is this posibble and if so could you give me the code and instructions to do it?.

Kind regards.

Colin.


Advertisement
View Answers

July 23, 2011 at 11:13 AM


<html>
<head>
<script type="text/javascript">
function showComment(){ 
var data=document.getElementById("text").value;

     alert(data);
     document.getElementById("comment").style.visibility= "visible";
     document.getElementById("lab").innerHTML=data;
     }

</script>
</head>
<body>
Post Comment: <br><textarea id="text" rows="10" cols="40"></textarea><br>
<label id="comment" style="visibility:hidden"><b>Comments: </b></label><label id="lab"></label>
<br>
<input type="button" value="Post" onclick="showComment();">
</body>
</html>


July 24, 2011 at 1:06 AM


This is fantastic and thank you very much for the code. Could I impose a little more and just ask if it is possible that this code could be extended to!.

include other comments entered rather than over writing the first comment made. E.g:

This user type a positive comment.

This user wrote a negative comment.

This user wrote about the others comment.

Etc.

Many thanks.

Colin.



Related Tutorials/Questions & Answers:
Advertisements
 

 

 

DMCA.com