[JavaScript]TextArea to Div

[JavaScript]TextArea to Div




<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>

<script type="text/javascript">
 function    HTMLEnCode(str)   
   {   
         var    s    =    "";   
         if    (str.length    ==    0)    return    "";   
         s    =    str.replace(/&/g,    "&gt;");   
         s    =    s.replace(/</g,        "&lt;");   
         s    =    s.replace(/>/g,        "&gt;");   
         s    =    s.replace(/    /g,        "&nbsp;");   
         s    =    s.replace(/\'/g,      "&#39;");   
         s    =    s.replace(/\"/g,      "&quot;");   
         s    =    s.replace(/\n/g,      "<br>");   
         return    s;   
   }   
   function    HTMLDeCode(str)   
   {   
         var    s    =    "";   
         if    (str.length    ==    0)    return    "";   
         s    =    str.replace(/&gt;/g,    "&");   
         s    =    s.replace(/&lt;/g,        "<");   
         s    =    s.replace(/&gt;/g,        ">");   
         s    =    s.replace(/&nbsp;/g,        "    ");   
         s    =    s.replace(/&#39;/g,      "\'");   
         s    =    s.replace(/&quot;/g,      "\"");   
         s    =    s.replace(/<br>/g,      "\n");   
         return    s;   
   }   
$(function(){
    $("#btnMove").click(function(){
        var myIn = $("#myIn");
        var myOut = $("#myOut");
        var myText = $("#myText");
        
        var str = HTMLEnCode(myIn.text(),true);
        myOut.html(str);
        myText.text(str);
    });
});
</script>

</head>
<body>
    <form name="mainForm" id="mainForm" method="get" action="">
        <textarea name="myIn" id="myIn"></textarea><br />
        <input type="button" name="btnMove" id="btnMove" value="move" /><br />
        <div name="myOut" id="myOut"></div>
        <div name="myText" id="myText"></div>
    </form>
</body>
</html>

image