| Home | Hotscript | Downloads  
Text Link Ads

Tutorial - PHP
Categories
Blog [2]
Communication [1]
Site Stats [3]
Skin/Template [2]
Timer & Counter [1]
Tools [3]
Tutorial - Photoshop
Categories
Graphics [5]
Special Effects [2]
Text Effect [2]
Download - PHP Scripts
myBloggie - D/L
Advanced Blog System
myBloggie's Home
myBloggie's Demo
user: guest
pwd: pass
myEvent
Dynamic Calendar with Events
Bloggielite
New Generation Blog
TNX?
Our best karaoke at bargain prices
Tablecloths
Beratung, Verkauf und Kundendienst Waschmaschinen fuer alle Fabrikate.
Wicked NYC

PHP/MySQL Tutorial
 
Add Smilies into your Guestbook/Blog Script Part 1
Written by : Sean
Date : 2003-07-08
[Back]  [Home]  


Wonder how smiley faces are automatically added your guestbook or blog script whenever you type :) in your form's textarea ? This tutorial will guide you thru on how to write a simple script to added smiley to your script.

1) Create a TextArea Form

First of all, you need to have create a form. You need to have a form to enter messages in any guestbook or blog script right ? example of the form is as below.

Code:
<form action="post.php" method="post" name="post" >
<textarea name="message" rows="10" cols="35" wrap="virtual" style="width:450px" ></textarea>
<input type=submit value="Submit" name=submit>
</form>

2) Create A Link to add short smiley code  eg :) without typing

After creating a form, you may want to create a button of a link to drop short smiley code to the textarea without type.  All you need is a javascript.

please make sure that  form name &  the textarea name defined in the form

In the form (please note on the bold & italic/undeline words)

<form action=".PHP_SELF." method="post" name="post" >
<textarea name="message" rows="10" cols="35" wrap="virtual" style="width:450px" ></textarea>

In the javascript you need to define the name!

document.post.message.value = document.post.message.value + which;

 

Code:

<SCRIPT LANGUAGE='JavaScript'>
/** smiley coded by Sean **/
  <!--
  function Smiles(which) {
  document.post.message.value = document.post.message.value + which;
  }
  //-->
</SCRIPT>


After creating the javascript to enable you to drop the short smiley code to the textarea. Now, you need to create a link or a button as well
 
icon_smile.gif

Download this above smiley image into the directory "images" and create a link as below

Code:
<A HREF="javascript:Smiles(':)')"><IMG SRC="images/icon_smile.gif" BORDER=0 alt=":)"></A>

You have just create a form with button/link that enable you to drop the smiley short code into the text area.

Next part we will look into how to process form message & replace smiley short codes with smilies images. Please come back again for 2nd Part ! 



myWebland © 2003, 2004 myWebland Group
myWebland | wahsei | Contact Us | Privacy Statement