SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2010
    Posts
    61
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thumbs up Help,help,Help me insert function to textarea

    i have this function javascript

    <script language="javascript">
    function ham(){
    document.BM.message.value+="Happy New Year"
    }
    </script>

    <form name="BM">
    <textarea name="message" id="textarea" rows="10" cols="60" tabindex="1"></textarea>

    I want to insert ham() to <textare ...> like below picture


    Help me!
    Thanks everyone very much!

  2. #2
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,191
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    This should do the trick

    Code JavaScript:
    function ham(){
        document.forms.BM.message.value += "Happy New Year";
    }
     
    window.onload = ham

  3. #3
    SitePoint Enthusiast
    Join Date
    Oct 2010
    Posts
    61
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I tried but this function don't run. help help

  4. #4
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,191
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Do you have a test page where i can see this?

  5. #5
    SitePoint Wizard
    Join Date
    Dec 2003
    Location
    USA
    Posts
    2,582
    Mentioned
    29 Post(s)
    Tagged
    0 Thread(s)
    Instead of value, try innerHTML.

  6. #6
    SitePoint Addict bronze trophy AllanP's Avatar
    Join Date
    Sep 2010
    Location
    Australia
    Posts
    298
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    You need to call the function. This works:

    function ham() { document.BM.message.value="Happy New Year"; }

    window.onload=ham;

  7. #7
    SitePoint Enthusiast
    Join Date
    Oct 2010
    Posts
    61
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by AllanP View Post
    You need to call the function. This works:

    function ham() { document.BM.message.value="Happy New Year"; }

    window.onload=ham;
    OKies, Thanks you very much!!!


Tags for this Thread

Bookmarks

Posting Permissions

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