• Howdy! Welcome to our community of more than 130.000 members devoted to web hosting. This is a great place to get special offers from web hosts and post your own requests or ads. To start posting sign up here. Cheers! /Peo, FreeWebSpace.net
managed wordpress hosting

smilies in textbox

what i mean is.. i wanna make a guestbook, and i want everyone can put a smilies in the textbox.
just like in this forum, you click a smilies and then it's added to the box.that's all..
 
1st you need to know the search and replace functions in the language you used in your guestbook and use javascript for inserting smiley code in the textbox.
Here is an idea of the javascript:

Code:
<script type="text/javascript">
function insert_smile() {
document.forms['myform'].elements['mytextbox'].value += ' :)';
}
</script>

<form name="myform">
<input type="button" value=" :) " onclick="insert_smile();" />
<textarea id="mytextbox"></textarea>
</form>
 
To follow on from that, if your guestbook is php based, which i guess it most likely is, you can then replace the smiley code in your output with something like.

function replace_smiley($text)
{
$text = str_replace(":)","<img src='smiley.gif' alt=':)'>", $text);

return $text;
}

Then if your output for the messages was say $message you would just:

PHP:
echo replace_smiley($message);

lol, found a vBulletin bug :D haha, can't use php tags had to use quote, just replace the smiley face with : ) (no space) lol
 
Last edited:
not so smiling smiles

i'm using greymatter and i have the smiles all set up and there but when i click on one of the smile images and send the meassage all i get is the :) :O :( :D :p <---those things-
the image isnt being replaced-
any idea on how i can fix that?
thanks for any help in advance
rachel
http://sticky-fingers.org
 
i'm using greymatter and i have the smiles all set up and there but when i click on one of the smile images
and send the meassage all i get is the :O <---those things

what do you mean by that?
normally, what appears in the textbox is the code (like :|, :), etc) and not the image. what would change the code to image is another mechanism, for example, this function:

PHP:
function emoticon($dataWithSmileys,$smileyImageDir) {
    // array of emoticons and pictures 
    $pic = array( 
        ":(" => "frown.gif", 
        ":(" => "frown.gif", 
        ":)" => "smile.gif",    
        ":D" => "biggrin.gif", 
        ":o" => "redface.gif", 
        ":p" => "tongue.gif", 
         ";)" => "wink.gif" ); 

    //Manipulate directory
    $realDir = preg_replace("/\/*$/","",$smileyImageDir);

    // list emoticons 
    if(!$dataWithSmileys) {
        echo "<p>\n"; 
        foreach($pic as $i => $j) {
            echo "<img src=\"$realDir/$j\" border=\"0\" alt=\"$i\" /> $i  
        <img src=\"$realDir/$j\" border=\"0\" alt=\"$i\" /><br />\n"; 
        } 
        echo "</p>\n"; 

    } 
    else {
        $b = $dataWithSmileys; 

        foreach($pic as $i => $j) {
            $c = addcslashes($i,"("); 
            $b = ereg_replace("[[:space:]]". $c ."[[:space:]]","  
        <img src=\"$realDir/$j\" border=\"0\" alt=\"$i\" /> ",$b); 
        } 

        return $b; 
    } 
}

it will convert the each listed emoticon into its picture. the given parameter are $dataWithSmileys (which may be taken from database) and $smileyImageDir (directory where the images are placed)
 
ouch.... i find several bugs here.
i just tried to insert my code in PHP, but FWS parsed it :p...
haha.. another task for vBulletin author.

so, my code wouldn't run.

and i'm not that diligent to rewrite it :confused2
 
;[

awww-thanks for even trying to help-your very sweet to even bother-
maybe one day my savior will come along and get my greymatter smiles working-
till them i'm stuck here waiting and a wishing lol
<33ray
http://sticky-fingers.org
edit- i think one of the paths is wrong-anyone care to HELP-PALEASE/edit-
 
Last edited:
Back
Top