View Full Version : smilies in textbox
ransky
January 10th, 2004, 05:04
how can we put smilies in a textbox?
i.e in this forum.
ransky
January 10th, 2004, 05:22
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..
bloodyveins
January 10th, 2004, 08:56
javascript would do that..
google and try it first...
kaca
January 11th, 2004, 11:31
It can use VB code.
kabatak
January 12th, 2004, 02:47
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:
<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>
Loon
January 18th, 2004, 12:19
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:
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
sergeantrawr
February 11th, 2004, 16:39
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
bloodyveins
February 12th, 2004, 10:11
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:
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)
bloodyveins
February 12th, 2004, 10:18
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
sergeantrawr
February 12th, 2004, 11:03
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-
Powered by vBulletin® Version 4.1.7 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.