scriptygoddess

16 Aug, 2002

Add Smiley's to text

Posted by: Jennifer In: Scripts

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)

75 Responses to "Add Smiley's to text"

1 | Happy Pills

February 22nd, 2003 at 11:05 pm

Avatar

Smile 😀
Huge thanks to scriptygoddess – as always – for super-easy smilies! I have wanted to

2 | Happy Pills

February 22nd, 2003 at 11:08 pm

Avatar

Smile 😀
Huge thanks to scriptygoddess – as always – for super-easy smilies! I have wanted to

3 | Design-A-Blog

February 24th, 2003 at 2:09 am

Avatar

Late Night Musings
It's 1 AM. Am I really too tired to try implementing clickable smilies to my blogs? Bah. This is going

4 | Live in the Delirious Cool

March 4th, 2003 at 2:59 pm

Avatar

Making linking even easier.
I've been ignoring the MTMacros plugin because I got on the smiley bandwagon early, but link shortcuts sure would come in handy.

5 | leo-lady's gc

March 16th, 2003 at 12:35 pm

Avatar

Smilies
I want some smilies for my comments. I tried the scriptygoddess script, and I got as far as having a clickable smiley. It says :smirk:, but when I preview/posted, it SAID :smirk: instead of showing it. Bah! Stupid script, why…

6 | Unix Gal

April 22nd, 2003 at 4:52 pm

Avatar

Adding smileys to your blog
This is how I implemented my smilies. It's a combination of the ideas from ScriptyGoddess, The Girlie Matters and my

7 | Halla's Ranting: Long Form

June 29th, 2003 at 3:55 pm

Avatar

One cool thing done.
If you would leave me a comment to notice, I now have smileys, courtesy of Scripty Goddess! Yay for smilies! Other stuff I want to do is below in no particular order. -remove the popups from MT (like Jeremy Zawodny…

8 | The Long Letter

July 7th, 2003 at 10:21 pm

Avatar

Yet another trick in place
Alrighty then — more goodies are in place! To go with the (re-)addition of the smiley hack, I've combined a couple other ideas to really enhance the comment postings here.

9 | geekalicious.net

July 19th, 2003 at 9:43 pm

Avatar

Smilies and Post to blog via email
Today was busy! I think people know by now that Rick is home and will watch Kayla while I help them :) I helped Tudy iron out her smilies issues. We used a combination of Girlie's and Lisa's (part 1,…

10 | Happy Pills

September 3rd, 2003 at 1:47 pm

Avatar

Kick ass!!
Okay, so somewhere along the line in changing layouts and making sure crap worked properly,…

11 | MartieGras

September 5th, 2003 at 8:18 pm

Avatar

Call me neurotic
After all my hard work on implementing my smilies in my comments I come to find out that they only work in Internet Explorer. They don't work in Mozilla or Netscape browsers. Now I don't know how many people actually use those browsers or any others, o…

12 | Bloggie Broad

October 6th, 2003 at 3:00 am

Avatar

Smiley Help, Please….
I want to add smiley graphics to BB (check out Jenn's comment field options to see an example), but I need some pointers — where'd…

13 | Bloggie Broad

October 26th, 2003 at 1:31 am

Avatar

Reverb: Bloggie Scripty Fun
I'm organizing BB and deleted the posts revolving around my techie mess from earlier in the week, since it was an easy fix. I like…

14 | Bloggie Broad

October 27th, 2003 at 10:13 pm

Avatar

All Quiet on the Bloggers' Front
What's up with everyone today? It figures — the days I feel like consistently blogging are the days that everyone else decides to tend to…

15 | Bloggie Broad

November 23rd, 2003 at 5:49 pm

Avatar

Reverb: Bloggie Scripty Fun
I'm organizing BB and deleted the posts revolving around my techie mess from earlier in the week, since it was an easy fix. I like…

16 | Glimpse of a Grrl

January 2nd, 2004 at 5:14 pm

Avatar

Adding smileys to your blog
This is how I implemented my smilies. It's a combination of the ideas from ScriptyGoddess, The Girlie Matters and my own thoughts. You need to get Brad Choate's MTMacro plugin and you have to add some javascript to your site….

17 | /Blog

February 1st, 2004 at 6:02 pm

Avatar

Smilies
Added smilies to my comments! How to……

18 | MartieGras

April 13th, 2004 at 9:24 pm

Avatar

Upgrading to MT 2.661
Just because I want to. UP

19 | MartieGras

April 13th, 2004 at 10:05 pm

Avatar

Upgrading to MT 2.661
Just because I want to. UP

20 | MartieGras

April 29th, 2004 at 1:53 pm

Avatar

Call me neurotic
After all my hard work on implementing my smilies in my comments I come to find out that they only work in Internet Explorer. They don't work in Mozilla or Netscape browsers. Now I don't know how many people actually…

21 | Born In A Zoo

May 8th, 2004 at 12:16 pm

Avatar

BTW
YAY for Kit-Kat! YAY for Kit-Kat! YAY for Kit-Kat! She figured out that I was a retard and fixed a boo-boo in my stylesheet. Now my blog looks good in Mazola Mozilla….

22 | Glimpse of a Grrl

May 23rd, 2004 at 10:23 pm

Avatar

Adding smileys to your blog
This is how I implemented my smilies. It's a combination of the ideas from ScriptyGoddess, The Girlie Matters and my own thoughts. You need to get Brad Choate's MTMacro plugin and you have to add some javascript to your site….

23 | Patrick

July 24th, 2004 at 2:17 am

Avatar

Okie Dokie. I have what I think is a simple question. My MTMacros are defined and running great. A little too well. Every time the word Nick appears in my entries, they are automatically hyperlinked to a site (the behaviour that should happen). But in one entry I need the word Nick to NOT be touched by the macro. How can I do that? Thanks!

24 | Tari

October 11th, 2004 at 4:13 pm

Avatar

I'm trying to get my smilie code window (an onClick pop-up) to put the smilies into the tag board on my main page, but I can't get it to work. Here's the site I'm trying to get it to work on:

Tari's Realm

25 | Chari

February 18th, 2005 at 2:43 pm

Avatar

Thanks so much! I got it working perfectly the first time around… no tinkering!

Featured Sponsors

Genesis Framework for WordPress

Advertise Here


  • Scott: Just moved changed the site URL as WP's installed in a subfolder. Cookie clearance worked for me. Thanks!
  • Stephen Lareau: Hi great blog thanks. Just thought I would add that it helps to put target = like this:1-800-555-1212 and
  • Cord Blomquist: Jennifer, you may want to check out tp2wp.com, a new service my company just launched that converts TypePad and Movable Type export files into WordPre

About


Advertisements