Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 11th, 2012  |  syntax: None  |  size: 0.51 KB  |  hits: 9  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How to use javascript to get html special characters in text input
  2. <script type="text/javascript">
  3. function qpush(a) {
  4.     document.getElementById('input').value += a;
  5. }
  6.  
  7. function show(a) {
  8.     alert(document.getElementById('input').value);
  9. }
  10. </script>
  11.  
  12. <input type="text" id="input" />
  13. <input type="button" onclick="qpush('&pi;');" value="&pi;" />
  14. <input type="button" onclick="show()" value="go" />
  15.        
  16. <button type="button" value="&pi;">π</button>
  17.        
  18. document.getElementById('input').value.replace(/π/g,"&pi;");