SitePoint Sponsor |
|
User Tag List
Results 1 to 2 of 2
Thread: Image Click Insert Text
-
Jun 29, 2007, 02:44 #1
- Join Date
- Jul 2004
- Location
- Cape Town, South Africa
- Posts
- 2,880
- Mentioned
- 48 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>
-
Jun 29, 2007, 05:46 #2
- 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