• I created a button that appears in the post editor in html mode.

    The button opens a new window with a form containing info from the database in a single textarea.

    How do I transfer the data from that child window to the parent post.content?

    I have tried normal javascript functions that work as standalones but, there is something with the editor in WordPress that is preventing the javascript in the child from inserting into the post form content area, I think.

    Does anyone know how to do that? Maybe suggest a simple plugin that I can dissect to find out how?

    Thanks for your help…

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter zentode

    (@zentode)

    Ok, I figured it out. I also figured out I need some sleep… I was serving the pop up from a different cpanel account… duh..sorry.

    <script langauge="javascript">
    function insertInPost(formguts) {
    // IE support
    if (opener.document.post.content.selection) {
    opener.document.post.content.focus();
    sel = opener.document.post.content.selection.createRange();
    sel.text = formguts;
    }
    // MOZILLA/NETSCAPE support
    else if (opener.document.post.content.selectionStart || opener.document.post.content.selectionStart == 0) {
    var startPos = opener.document.post.content.selectionStart;
    var endPos = opener.document.post.content.selectionEnd;
    opener.document.post.content.value = opener.document.post.content.value.substring(0, startPos) + formguts + opener.document.post.content.value.substring(endPos,opener.document.post.content.value.length);
    }
    else {
    opener.document.post.content.value += formguts;
    }
    }
    </script>
    <a href="#" onclick="insertInPost('thiswillbeformgutsfromform')">Is This Thing On?</a>

    Puts data after cursor position in post.content’s textarea…

    Any sterilization and other additions are welcome.

    Do you think it is possible to put data into other inputs or textareas, like the excerpt? Trying to find some documentation for this.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to insert into post content from popup’ is closed to new replies.