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

Link to comment
Share on other sites

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 ?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.