PDA

View Full Version : emo-icons question?


angst
04-20-2004, 09:15 PM
i have setup emo icons on a forums that i'm putting together for my web site.
only one question, I have a list of emo-icons just under the textarea,
and it's just a simple text area, not with formatting like this one.

how can i have it so users only have to click on the icons to have the code appear in the testarea?

any examples would be great as i'm very new to javascript.

thanks in advance for your time!

sad69
04-20-2004, 10:56 PM
I don't know much about forums, and this is sort of dependent on how your emoticons are setup... I'm just going to assume that they are images.


<script>
function insertEmoticon(txtIcon) {
var txtarea = document.getElementById(msgId);
txtarea.value += txtIcon;
}
</script>

<img ... onClick="insertEmoticon(':)');">
...

<textarea name="msg" id="msgId"></textarea>


I think that should work.. Let me know how it works out for you, or if you were actually trying to accomplish something else.

Sadiq.

angst
04-21-2004, 01:27 AM
no thats doesn't work,

I just change it to:

<script>
function insertEmoticon(txtIcon) {
var txtarea = document.getElementById(msgId);
txtarea.value += txtIcon;
}
</script>

<img src="blah.gif" onClick="insertEmoticon(':)');">
...

<textarea name="msg" id="msgId"></textarea>

and i get this error:

'null' is null or not an object

angst
04-21-2004, 03:48 PM
can any one please help me with this?
I thought it was something simple, but maybe not?

thanks again for your time.
ken

Willy Duitt
04-21-2004, 04:01 PM
To get your changes to work.
Wrap msgId in quotes.

eg: var txtarea = document.getElementById('msgId');

.....Willy

angst
04-21-2004, 04:32 PM
that did the trick,
thanks! :thumbsup:

sad69
04-21-2004, 05:33 PM
Oops! Sorry about missing those quotes! Thanks Willy for picking that up!

Sadiq.