I'm using this script on my site, and I just realized I never documented it here. Bascially this script will add whatever code you want to the text box you specify. On my blog, I use it to add smiley icons (you click on a smiley icon, and the code is written for you). There's another script that Lynda had posted on her site (the link I have doesn't work anymore) that will scan your text and replace with the actual image, but it involves hacking into a file that I'd rather not play around with… I've heard too many horror stories.
Put this wherever you want.. between the <head> </head> tags or even somewhere in the body of your page
<script language="javascript">
<!–
function writeImgTag(code)
{
var cache = document.comments.text.value;
this.code = code;
document.comments.text.value = cache + " <img src='/images/" + code + ".gif'> ";
document.comments.text.focus();
}
//–>
</script>
change comments to the name of the FORM (it's specified in the <form> tag)
change text to the name of the textarea form element you want the code to be written into
change that image path to wherever you keep your images (if you want it to write something else… just change that whole line in the quotes)
Then for your smiley images, write them in the html like this:
<img onClick="writeImgTag('smile')" src="/images/smile.gif" border=0>
if you wanted it to write the "sad" image – you'd do this:
<img onClick="writeImgTag('sad')" src="/images/sad.gif" border=0>
(this all assumes you have a smile.gif, and a sad.gif in a folder "images" (in your root directory) – if it's somewhere else, or if it's named something else, change the code as neccessary…
When you clicked on the smile image, it would put the code for it in the text box (so if you wanted to allow your users to put smile images, they could do it that way, without having to type the code to the smile you had available)