SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Mentor NightStalker-DNS's Avatar
    Join Date
    Jul 2004
    Location
    Cape Town, South Africa
    Posts
    2,878
    Mentioned
    46 Post(s)
    Tagged
    0 Thread(s)

    Image Click Insert Text

    Hey guys

    I have a textarea on my page and images at the bottom. I want to use some javascript that when you click on the image, it inserts it into the text area with the ID txtEntry.

    Like emoticons on forums.

    I dnt no much about javascript. Please help me.

    Thanks for any feedback

    this is what ive tried so far:
    <a href="javascript:insert_link()"><img src="link"></a>

    <script type="text/javascript" language="javascript">
    function insert_link()
    {
    var link = 'test';

    document.Form1.txtEntry.value+=link;

    }

    }
    </script>

  2. #2
    SitePoint Wizard gRoberts's Avatar
    Join Date
    Oct 2004
    Location
    Birtley, UK
    Posts
    2,439
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    well nearly there, replace document.Form1.txtEntry.value with

    document.getElementById('txtEntry').value+=link;

    but i'm sure you'd want to be able to add links where the cursor is not to the end of the text.



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
  •