views:

96

answers:

3

I know I did ask this question earlier but here is my problem in details:

  1. if I copy the text from textarea1 to textarea2 using a JavaScript program, it works fine
  2. if I attach the teaxtarea1 with a WYSIWYG editor then it refuses to work. And I am using openWYSIWYG.

Why can't I can copy the plain text from textarea1 when it is attached to a WYSIWYG?

The code I am using for copying it without a WYSIWYG is:

function postChange() {

    document.forms["form1"].textarea2.value = document.forms["form1"].textarea1.value;

}
A: 

I don't know this "WYSIWYG", although I think I know what you mean. Could it be that when you apply it to a textarea, said textarea's value no longer holds the text? The text is probably in some property of the WYSIWYG object. Or something.

Can you post a link to the library?

And look what I found in their "Save" code:

WYSIWYG.updateTextArea(n);

Try with that and then get the value of the textarea.

Victor
"What you see is what you get" - a rich text editor perhaps.
Rew
exactly thats what am thnkng too...here's the link: http://www.openwebware.com/
deadboy
A: 

How about this?

    function getIFrameDocument( id )
    {
            var iframe = document.getElementById(id);

            if (iframe.contentDocument) {
                    // For NS6
                    return iframe.contentDocument; 
            } else if (iframe.contentWindow) {
                    // For IE5.5 and IE6
                    return iframe.contentWindow.document;
            } else if (iframe.document) {
                    // For IE5
                    return iframe.document;
            } else {
                    return null;
            }
    }

    function getContents()
    {
            return getIFrameDocument('wysiwygtextarea1').body.innerHTML;
    }
Rew
nothing ... completely blank
deadboy
A: 

That's because what you see isn't a textarea but an iframe with a full HTML page inside.
There is a hidden textarea, but it doesn't seem to be updated in real time.

The method given by Rew should work (for Firefox, that's contentDocument) but it returns HTML code (generated by the widget), not plain text.
You might want to use body.plainText (instead of body.innerHTML) on Firefox, not sure for other browsers.

Alternatively, check your widget's API to see if they don't offer such plain text access.

PhiLho