Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Mar 2011
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Question Populating textarea

    I am fairly new at Javascript, but there is something happening I do not understand. Please someone explain it to me and help with a solution.

    In the function, I pull data from an URL and I have done this with several different data fields and populate the HTML input, option, and check boxes with no problem with the following method.

    Code:
    document.getElementById("othertxt").value=strValue;
    document.getElementById("radsig").checked=true;
    document.getElementById("eventtime").value=strValue;
    But for some reason this method for textarea does not work and I know that there is a value in strValue because check it right before the line of code.

    Code:
    document.getElementById("othertxt").value=strValue;
    Is textarea just treated differently? I have searched the internet and seen examples but for some reason I can not find the correct solution.

  • #2
    Senior Coder
    Join Date
    Jan 2005
    Location
    Memphis, TN
    Posts
    1,788
    Thanks
    8
    Thanked 131 Times in 129 Posts
    This works just fine for me:

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head>
    <body>
    <input type="checkbox" id="radsig" />
    <input type="text" id="eventtime" value="" />
    <textarea id="othertxt" rows="10" col="3"></textarea>
    <script type="text/javascript">
    strValue = "hello";
    document.getElementById("othertxt").value=strValue;
    document.getElementById("radsig").checked=true;
    document.getElementById("eventtime").value=strValue;
    </script>
    </body>
    </html>
    Stop making things so hard on yourself.
    i is tugbucket :: help raise tugburg :: Whitehaven Kiwanis

  • #3
    New to the CF scene
    Join Date
    Mar 2011
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I am so sorry for taking up your time, it would help if I spelled othertext correctly.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •