Title: How insert the content with JavaScript ( textarea ).
Last modified: August 22, 2016

---

# How insert the content with JavaScript ( textarea ).

 *  Resolved [mythemes](https://wordpress.org/support/users/mythemes/)
 * (@mythemes)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/how-insert-the-content-with-javascript-textarea/)
 * For sample textarea and wordpress visual editor I use the code
 *     ```
       var code = mythemes_get_shortcode( sh ); // return [posts count="3"/]
   
       jQuery(function(){
       if( jQuery( 'div#wp-content-wrap' ).length &&
           jQuery( 'div#wp-content-wrap' ).hasClass( 'html-active' ) ) {
   
         var text = jQuery( 'textarea#content' ).val();
         jQuery( 'textarea#content' ).val( text + code );
       }
       else{
         if( typeof tinyMCE == 'object' )
           tinyMCE.execCommand( 'mceInsertRawHTML', false, code );
         }
       });
       ```
   
 * When is installed the WP Editor plugin I try to use an additional code for the
   case with the textarea.
 *     ```
       var mythemes_sh_editor;
   
       ...
   
       if( jQuery( 'div#wp-content-wrap' ).length &&
           jQuery( 'div#wp-content-wrap' ).hasClass( 'html-active' ) ) {
   
         var text = jQuery( 'textarea#content' ).val();
         jQuery( 'textarea#content' ).val( text + code );
   
         if( typeof CodeMirror == 'function' &&
             typeof mythemes_editor == 'undefined' ){
   
           var textArea = document.getElementById('content');
           var mythemes_editor = CodeMirror.fromTextArea( textArea );
           mythemes_editor.getDoc().setValue( text + code );
         }
         else if( typeof CodeMirror == 'function' ){
           mythemes_editor.getDoc().setValue( text + code );
         }
       }
       ...
       ```
   
 * but unfortunately it does not work.
 * please, can you help me to make it to work correctly.
 * [https://wordpress.org/plugins/wp-editor/](https://wordpress.org/plugins/wp-editor/)

Viewing 1 replies (of 1 total)

 *  Plugin Author [benjaminprojas](https://wordpress.org/support/users/benjaminprojas/)
 * (@benjaminprojas)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/how-insert-the-content-with-javascript-textarea/#post-5932149)
 * mythemes,
 * Its hard to determine what the issue might be without seeing a bigger picture
   of what you are doing. Unfortunately, I am not able to fully troubleshoot this
   for you. I would recommend checking your JS console and if there is an issue 
   there, resolve that. Otherwise, reach out to the folks at CodeMirror.net to see
   if they might have a solution.

Viewing 1 replies (of 1 total)

The topic ‘How insert the content with JavaScript ( textarea ).’ is closed to new
replies.

 * ![](https://ps.w.org/wp-editor/assets/icon-256x256.png?rev=1184262)
 * [WP Editor](https://wordpress.org/plugins/wp-editor/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-editor/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-editor/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-editor/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-editor/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-editor/reviews/)

## Tags

 * [content](https://wordpress.org/support/topic-tag/content/)

 * 1 reply
 * 2 participants
 * Last reply from: [benjaminprojas](https://wordpress.org/support/users/benjaminprojas/)
 * Last activity: [10 years, 11 months ago](https://wordpress.org/support/topic/how-insert-the-content-with-javascript-textarea/#post-5932149)
 * Status: resolved