I was pointing at the smiles
when you click on the image text appears in here how? ive been tring for ages and I aint managed to get it working.
anyone help please
Andrew
Moderator: General Moderators
Code: Select all
$image = "<a href="javascript:emoticon('". stripslashes($smiliecode[$i]) ."')"><img border="0" src="../images/smilies/". $imagename[$i] .""></a>";Code: Select all
<script language="javascript" type="text/javascript">
<!--
//This script goes at the top of the page
function emoticon(smiliecode) {
document.thread.posttext.value += smiliecode+" ";
document.thread.posttext.focus();
}
//-->
</script>Code: Select all
<?
//======================================================================
// Bionic Donkey Research Facility Online :: require/smilie.php
//
// Copyright (C) 2002-2003 Josh Benoît. All rights reserved.
// This program is free software licensed under the
// GNU General Public License (GPL).
//
// This code may be redistributed as long as this text is present.
// This text may be edited but only to state addition made the script.
//
// Bionic Donkey Research
// http://bionicdonkey.host.sk
//
//=====================================================================
//---Emoticons function---\\
function addSmilies($input) {
//---Database Stuff---\\
require("Connections/donkey.php");
mysql_select_db($database_donkey, $db);
$smilies_query = mysql_query("SELECT * FROM emoticons", $db);
while($row = mysql_fetch_array($smilies_query)) {
if(!isset($smiliecode)) {
$smiliecode = array($row['code']);
} else {
array_push($smiliecode, $row['code']);
}
if(!isset($imagename)) {
$imagename = array($row['imageName']);
} else {
array_push($imagename, $row['imageName']);
}
}
$elements = count($smiliecode);
$tmp = count($imagename);
if($elements !== $tmp) {
die("Something's not working in DB");
}
for($i = 0; $i < $elements; $i++) { // Do while value of $i is less than than the total amount of emoticons
$image = "<img src="../images/smilies/". $imagename[$i] ."">";
$output = str_replace($smiliecode[$i], $image, $input); // Replace the symbol with the image
$input = $output; // Add change string back into the input and continue looking for symbols (if loop is still valid)
}
return $output;
}
?>Code: Select all
<HTML>
<HEAD>
<TITLE></TITLE>
<script LANGUAGE="JavaScript">
function storeCaret (textEl)
{
if (textEl.createTextRange)
textEl.caretPos = document.selection.createRange().duplicate();
}
function insertAtCaret (textEl, text)
{
if (textEl.createTextRange && textEl.caretPos)
{
var caretPos = textEl.caretPos;
caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
}
else
textEl.value = text;
}
</script>
</HEAD>
<BODY>
<FORM>
<textarea rows="5" name="ta_message" cols="20"ONSELECT="storeCaret(this);"ONCLICK="storeCaret(this);"ONKEYUP="storeCaret(this);"></textarea>
<INPUT TYPE="button" VALUE="Click Me"
ONCLICK="insertAtCaret(this.form.ta_message,'Appearing text');">
</FORM>
</BODY>
</HTML>Code: Select all
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE></TITLE>
<META http-equiv=content-type content=text/html;charset=iso-8859-1>
<script language="Javascript">
function smile()
{
smileText=document.getElementById('textarea1').value;
tempText1=smileText.substring(0,cursorPos);
tempText2=smileText.substring(cursorPos,smileText.length);
document.getElementById('textarea1').value=tempText1+":)"+tempText2;
cursorPos=smileText.length+2;
}
function keyPress(e)
{
var textlength=document.getElementById('textarea1').value;
if(navigator.appName == "Netscape")
var keypressed = e.which;
else
var keypressed = event.keyCode;
switch(keypressed)
{ case 37: // LEFT ARROW
cursorPos--;
// alert(cursorPos);
return;
case 39: // RIGHT ARROW
if (textlength.length>cursorPos)
cursorPos++;
// alert(cursorPos+" length: "+textlength.length);
return;
default: cursorPos++;
}
}
if(navigator.appName == "Netscape")
document.onkeydown = keyPress;
var cursorPos=0;
</script>
<BODY bgColor="#ffffee"><BR><BR>
<TEXTAREA id=textarea1 rows=10 cols=50 onkeydown="keyPress()"></textarea>
<input type=button value=Smilie onClick="smile();">
</FORM></BODY></HTML>