• So, what i’m trying to do is adding a Javascript snippet in wordpress admin new post page, so that when i click a button it fills up the CONTENT textarea where the body of the post goes. Adding it is not a problem, i’ve already done this, but for some reason filling up the content field doesn’t work.

    The textarea from the wordpress admin page is:

    <textarea rows='10' class='theEditor' cols='40' name='content' tabindex='2' id='content'></textarea>

    Also i tried to fill up the POST_TITLE input and it works fine. I know the problem might come from the JS scripts of wordpress for the content field, because it’s not a simple textarea, it’s a JS text editor. Any suggestions? And the JS snippet is:

    <script type="text/javascript">
    
        $("form").submit(function(){
            $("input[name$='post_title']").val("a letter");
            document.getElementById('content').innerHTML = "testing";
            return false;
        });
    
    </script>

    PS: jquery library already included

Viewing 2 replies - 1 through 2 (of 2 total)
  • We did something similar in this thread.
    https://www.ads-software.com/support/topic/limit-the-number-of-tags-added-to-a-post

    Importantly i think you’re missing a necessary jQuery wrapper, aka no conflict mode..

    Code in the thread above should give you enough to work from though..

    Hope that helps..

    Thread Starter cosminx200

    (@cosminx200)

    Hello Mark,

    Thanks a lot for your response, but unfortunately i didn’t manage to make it working, i’ve tried to rewrite the code using what you’ve done in that thread but had no luck.

    Here is the code:

    jQuery(document).ready(function($wj) {
            $wj("form").submit(function(){
                $wj("input[name$=\'post_title\']").val("a letter");
                $wj("#content").text("hi");
                return false;
            });
    });
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘wordpress new post content editor – change the value by document.getElementById’ is closed to new replies.