onClick insert a text in a text area

Hi there,
I’ve been searching for this function to complete my script. In brief I want to have a text area where I can write anything in it. And beside it I want to have a picture or a botton and if I clicked that botton it inserts a text in the text area. The idea is similare to the clickable smilies in this forum. Is there any pice of code that I can use to do this job to me?

Any help would be appreciated in advance :slight_smile:

Simple example:

    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <script type="text/javascript">
      function insertText(elemID, text)
        var elem = document.getElementById(elemID);
        elem.innerHTML += text;
      <textarea id="txt1"></textarea>
      <input type="button" value="Insert some text" onclick="insertText('txt1', 'Hello');">

Thanx jofa that worked just FINE :slight_smile:

How about the script that is used to post an image code in my post at this forum? I mean the prompt script which gives you the ability to add an image code in your post…May I have that pice of code too?

Thanx in advance


That’s cool but where can get the source code? I tried to view it’s source using the notepad But it didn’t worked fine.
May I have that source for the TAEditor???

okay thanx alot beetle I found my mistake. now it’s working just great thank youuuuuuuuuuuuuu :slight_smile:

Hey [b]jofa[/b] can I change the button into an image?? I tried to do it but I failed…plz


<input type=“image” …> maybe? :wink:
Or just an <img> with an onclick event handler added

Be careful with <input type=“image” …>, they submit the form when clicked!

…if you don’t return false ?

Correct :smiley:

It didn’t work and you can try that jofa :frowning: I simply need a smily system just like the one in here…

Thanx for the help