Results 1 to 3 of 3

Thread: javascript - click graphic to enter text into textarea

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2001
    Posts
    2

    javascript - click graphic to enter text into textarea

    Could someone explain how to...

    Hmm, I see the smilies here do what I'm wanting to do, but I don't understand the code.


    I'm wanting to do something exactly like on the response page on this forum, where you click the smiley face and it enters the code for it into the textarea. (But it's for another feature, not smilies.)

    Could someone give a brief explanation of the coding needed to do this?

    I'm seeing the javascript:smilie(':)') in the href tag, but I don't see how it is specifying where to place the text. I know there's gotta be more to it than that!

  2. #2
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    the function is probably something like this


    Code:
    function smilie(smile)
    {
      document.formname.textboxname.value = document.formname.textboxname.value + smile;
    }
    you would just replace formname with the name of your html form element and textboxname with that name of the textbox

    and in the onclick attribute for the img element put

    onclick="javacript:smilie('text to add')"
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  3. #3

    Thread Starter
    New Member
    Join Date
    Jun 2001
    Posts
    2

    Lightbulb 'Kay

    Thanks. That makes a lot more sense!

Posting Permissions

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



Click Here to Expand Forum to Full Width