Topic: I need some assistance with a popup script
I am currently trying to get a popup smiley script to function but I am a bit lost.
Here is what I have so far. I made an external file called: popup.php and a link in post.php. I am using the easy_bbcode mod and it works as far as displaying the smiley's. The problem is that I can't insert the smiley's when I click on them. I have pasted the code I am using and it is the same working code I have been using in the normal fashion, which by the way works. Can someone please tell me what I need to do to get it to work.
popup.php
<?php
define('PUN_ROOT', './');
define('PUN_ALLOW_INDEX', 1);
require PUN_ROOT.'include/common.php';
$page_title = pun_htmlspecialchars($pun_config['o_board_title']);
define('PUN_ALLOW_INDEX', 1);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title><?php echo pun_htmlspecialchars($pun_config['o_board_title']) ?>Smileys</title>
<link rel="stylesheet" type="text/css" href="style/<?php echo $pun_user['style'].'.css' ?>" />
<?php
if (!isset($bbcode_form))
$bbcode_form = 'post';
if (!isset($bbcode_field))
$bbcode_field = 'req_message';
?>
<script type="text/javascript">
<!--
function insert_text(open, close)
{
msgfield = (document.all) ? document.all.req_message : document.forms['<?php echo $bbcode_form ?>']['<?php echo $bbcode_field ?>'];
// IE support
if (document.selection && document.selection.createRange)
{
msgfield.focus();
sel = document.selection.createRange();
sel.text = open + sel.text + close;
msgfield.focus();
}
// Moz support
else if (msgfield.selectionStart || msgfield.selectionStart == '0')
{
var startPos = msgfield.selectionStart;
var endPos = msgfield.selectionEnd;
msgfield.value = msgfield.value.substring(0, startPos) + open + msgfield.value.substring(startPos, endPos) + close + msgfield.value.substring(endPos, msgfield.value.length);
msgfield.selectionStart = msgfield.selectionEnd = endPos + open.length + close.length;
msgfield.focus();
}
// Fallback support for other browsers
else
{
msgfield.value += open + close;
msgfield.focus();
}
return;
}
-->
</script>
</head>
<?php
// Display the smiley set
require_once PUN_ROOT.'include/parser.php';
$smiley_dups = array();
$num_smilies = count($smiley_text);
for ($i = 0; $i < $num_smilies; ++$i)
{
// Is there a smiley at the current index?
if (!isset($smiley_text[$i]))
continue;
if (!in_array($smiley_img[$i], $smiley_dups))
echo "\t\t\t\t\t\t\t".'<a style="cursor: pointer;" onclick="insert_text(\''.$smiley_text[$i].'\', \'\')"><img src="img/smilies/'.$smiley_img[$i].'" title="'.$smiley_img[$i].'" alt="'.$smiley_text[$i].'" /></a>'."\n";
$smiley_dups[] = $smiley_img[$i];
}
Thanks in advance for any help here.