Advertisement
perriercamille

tocharcode.html

May 5th, 2012
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <html>
  2.  
  3. <head>
  4. <title>Converter</title>
  5. <script language="JavaScript">
  6. function showCode()
  7. {
  8.     var inValue = document.getElementById('input').value;
  9.     var charValue = "javascript:String.fromCharCode(";
  10.     for(var i = 0; i < inValue.length; i++)
  11.     {
  12.     if(i==0)
  13.             charValue += inValue.charCodeAt(i);
  14.         else
  15.             charValue += ("," + inValue.charCodeAt(i));
  16.     }
  17.     charValue += ");";
  18.     document.getElementById('charcode').value = charValue;
  19.     document.getElementById('url').value = encodeURIComponent(inValue);
  20. }
  21. </script>
  22. </head>
  23.  
  24. <body>
  25. <form>
  26.     <h1>String</h1>
  27.     <p>
  28.         <textarea id="input" cols="80" rows="3"></textarea>
  29.     </p>
  30.     <input type="button" value="Go" onClick="showCode()" />
  31.     <h1>CharCode</h1>
  32.     <p>
  33.         <textarea id="charcode" cols="80" rows="3"></textarea>
  34.     </p>
  35.     <h1>URL Encodage</h1>
  36.     <p>
  37.         <textarea id="url" cols="80" rows="3"></textarea>
  38.     </p>
  39. </form>
  40. </body>
  41.  
  42. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement