Problem: so I warned the value of textarea by:
var source = document.getElementById('source').value; alert(source);
But the value of textarea warned, as it was at page load time. And I want to warn the current value of textarea . I also tried
$("form").submit(function(){
But it also did not help me. So how can I do this?
This is my code.
<html> <head> <title>Perl WEB</title> <script type="text/javascript" src="http://code.guru99.com/Perl1/codemirror.js"></script> <link rel="stylesheet" href="http://code.guru99.com/Perl1/codemirror.css" type="text/css" media="screen" /> <script src="http://code.jquery.com/jquery-1.10.2.min.js"></script> <script type="text/javascript" src="http://code.guru99.com/perl/perl.js"></script> <style> .CodeMirror { border: 1px solid #eee; } .CodeMirror-scroll { height: auto; overflow-y: hidden; overflow-x: auto; } </style> <script> $(document).ready(function(){ $("form").submit(function(){ alert("Submitted"); }); }); </script> <script type="text/javascript"> function execute() { p5pkg.CORE.print = function(List__) { var i; for (i = 0; i < List__.length; i++) { document.getElementById('print-result').value += p5str(List__[i]) } return true; }; p5pkg.CORE.warn = function(List__) { var i; List__.push("\n"); for (i = 0; i < List__.length; i++) { document.getElementById('log-result').value += p5str(List__[i]); } return true; }; p5pkg["main"]["v_^O"] = "browser"; p5pkg["main"]["Hash_INC"]["Perlito5/strict.pm"] = "Perlito5/strict.pm"; p5pkg["main"]["Hash_INC"]["Perlito5/warnings.pm"] = "Perlito5/warnings.pm"; var source = document.getElementById('source').value; alert(source); var pos = 0; var ast; var match; document.getElementById('log-result').value = ""; </script> </head> <body> <form> <textarea id="source" cols="70" rows="10"> say 'h'; </textarea> <div class="hint">This code is editable. Click Run to execute.</div> <input type="button" value="Run" onclick="execute()"/></br> Output:</br> <textarea id="print-result" disabled="true" rows="10" cols="70"></textarea></br> Log:</br> <textarea id="log-result" disabled="true" cols="70"></textarea> <script> var editor = CodeMirror.fromTextArea(document.getElementById("source"), { lineNumbers: true, indentUnit: 4, indentWithTabs: true, enterMode: "keep", tabMode: "shift" }); </script> </form> </body> </html>
So how can I get the current textarea value? Please help me guys.
user2372214
source share