Jump to content

getting textarea content with javascript


glenelkins

Recommended Posts

hi

 

im having trouble with this. here is some example code:

 

<script type="text/javascript">

    function get_textarea() {

        var area = document.getElementById ( 'testarea' );

        var content = area.innerHTML;

    }
</script>

<form action="" method="post" onSubmit="get_textarea();">
    <textarea name="testarea" id="testarea">CONTENT EXAMPLE TEXT</textarea>
    <input type="submit" value="Do" />
</form>

 

Ok so the problem is it grabs the content of the textarea, but if i type something new into the area all it picks up is the old content that was placed there when the page loads.

 

Even if i use

var area  = document.getElementsByName ( 'testarea' );
var content = area[0].value;

still produces the same result

just looked at this again. I have tiny_mce used on the textareas. If i take tiny_mce off, it actually reads the content of the area correctly... any idea why it wont read it with tiny_mce ?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.