{"id":1378,"date":"2022-08-30T15:16:02","date_gmt":"2022-08-30T15:16:02","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/15\/codemirror-how-to-get-textarea-value-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:16:02","modified_gmt":"2022-08-30T15:16:02","slug":"codemirror-how-to-get-textarea-value-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/codemirror-how-to-get-textarea-value-collection-of-common-programming-errors\/","title":{"rendered":"CodeMirror How to get Textarea value-Collection of common programming errors"},"content":{"rendered":"<p>I created a textarea to highlight text for C# code using CodeMirror. But when I try to get the value of textarea I&#8217;m failing.<\/p>\n<p>I&#8217;m creating my editor as<\/p>\n<pre><code>var editor = CodeMirror.fromTextArea(document.getElementById(\"txtCode\"), {\n    lineNumbers: true,\n    mode: \"text\/x-csharp\",\n    matchBrackets: true\n});\n<\/code><\/pre>\n<p>When I write some meaningless words and try to get value like this:<\/p>\n<pre><code>alert(document.getElementById(\"txtCode\").value); \n<\/code><\/pre>\n<p>It returns:<\/p>\n<pre><code>if(true){}else{}\n<\/code><\/pre>\n<p>When I try to get it like:<\/p>\n<pre><code>alert(document.getElementById(\"txtCode\").getValue());\n<\/code><\/pre>\n<p>The browser gives the error &#8220;Uncaught TypeError: Object # has no method &#8216;getValue'&#8221;<\/p>\n<p>How can I get this value?<\/p>\n<p id=\"rop\"><small>Originally posted 2013-11-15 09:07:22. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>I created a textarea to highlight text for C# code using CodeMirror. But when I try to get the value of textarea I&#8217;m failing. I&#8217;m creating my editor as var editor = CodeMirror.fromTextArea(document.getElementById(&#8220;txtCode&#8221;), { lineNumbers: true, mode: &#8220;text\/x-csharp&#8221;, matchBrackets: true }); When I write some meaningless words and try to get value like this: alert(document.getElementById(&#8220;txtCode&#8221;).value); [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1378","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1378","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=1378"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1378\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=1378"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=1378"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=1378"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}