PDA

View Full Version : Make pic append text to text area.



nordabeck
10-15-2006, 02:35 PM
Hello,

Beeing completely new to javascript im struggeling to find an example of making a click on a pic append a text connected to that pic to a text area.

something like <img src="catpic.gif" onClick('cat')>
then populate <textarea name="text1"...> with this...

Anyone have a small example to show me?

/Nub

jscheuer1
10-15-2006, 03:10 PM
<img src="catpic.gif" onclick="document.getElementById('catCap').innerHTML='I\'m a cat!'"><br>
<span id="catCap"></span>

nordabeck
10-15-2006, 03:21 PM
Hi, and thanks for the prompt reply!

This displays the text "I'm a cat"

but what Im really looking fore is a way fo getting it into a textarea and append it to any text I might have already enterd there, so that I can then use the form data from that field.

So instead of the
<span id="catCap"></span>
I need a way of inserting "I'm a cat" in:

<textarea id="catCap">
</textarea>

jscheuer1
10-15-2006, 04:17 PM
<img src="catpic.gif" onclick="document.getElementById('catCap').value+='I\'m a cat!'"><br>
<textarea id="catCap"></textarea>

nordabeck
10-15-2006, 04:21 PM
Thanks John!
Just what I was after :)
Lean and simple! (once you know how)

- Mikael