Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Javascript: how to set content of a text area

  • 19-04-2007 4:07pm
    #1
    Registered Users, Registered Users 2 Posts: 2,364 ✭✭✭


    Can some kind soul tell me how I can set the text inside a 'textarea' using javascript. I want to do this so I can use AJAX to change the text.

    I have this:
    var mytextarea= document.getElementById("mytextarea");
    mytextarea.setContent("new text");
    
    I saw the function getContent() somewhere on the net, but is it just a function somebody wrote and not part of javascript? It doesn't work anyway.


Comments

  • Closed Accounts Posts: 884 ✭✭✭NutJob


    is the textarea a div textbox or some micosoft asp thingy?

    try should work anyway


    var mytextarea= document.getElementById("mytextarea");
    mytextarea.setContent("new text");
    Also because im in a good mood today and you posted some code heres a crash cource in javascript for the lazy(like me).:)

    http://www.youtube.com/watch?v=UJBkQhA2CRA
    can also be found at the chays computer club web site in better quality.


  • Registered Users, Registered Users 2 Posts: 2,364 ✭✭✭Mr. Flibble


    NutJob wrote:
    is the textarea a div textbox or some micosoft asp thingy?

    try should work anyway


    var mytextarea= document.getElementById("mytextarea");
    mytextarea.setContent("new text");
    Also because im in a good mood today and you posted some code heres a crash cource in javascript for the lazy(like me).:)

    http://www.youtube.com/watch?v=UJBkQhA2CRA
    can also be found at the chays computer club web site in better quality.

    This is the code for the textbox
    <FORM NAME="myform">
    <td><TEXTAREA NAME="mytextbox" COLS=40 ROWS=19>stuff</TEXTAREA>
    </FORM>
    
    Are you saying the setContent() function should work?


    ps. i think you have the wrong youtube link.


  • Registered Users, Registered Users 2 Posts: 26 ast


    mytextarea.value = "new text";
    

    Otherwise check that getElementById() is finding your textarea


  • Registered Users, Registered Users 2 Posts: 2,364 ✭✭✭Mr. Flibble


    ast wrote:
    mytextarea.value = "new text";
    

    Otherwise check that getElementById() is finding your textarea

    Cool. That was the problem. Adding "id=myid" in the html textarea code fixed it. Thanks.


Advertisement