Проблема вот в чем, если нажимать на смайлы/теги для TEXTAREA №2, они будут отображаться в TEXTAREA №1. Помогите пожалуйста разобраться.
<?php
//Подключение к Базе данных
$sql = "SELECT c.`id`, c.`message`, c.`user`, c.user_id, DATE_FORMAT(c.`time`, '%H:%i') AS time, u.avatar, u.login, u.name, u.group, u.email, u.regdate FROM `chat` AS c LEFT JOIN `users` AS u ON u.id = c.user_id ORDER BY `id` DESC";
$Result = mysqli_query($CONNECT, $sql) or die( mysqli_error($CONNECT) );
while ($Row = mysqli_fetch_assoc($Result)) {
$Avatar = (empty($Row['avatar'])) ? 0 : $Row['avatar'].'/'.$Row['user_id'];
if ($_SESSION['USER_GROUP'] == 2) $EDIT = '<!-- Меню ред.материала --><ul id="edit"><li id="su"><a href><div style="padding:5px 5px 10px 10px;background-size:15px;"></div></a><ul style="height:17px"><li style="right:64px"><a href="/chat/control/com_delete/'.$Row['id'].'"><span id="edit-del" style="margin-top:-5px"></span></a><a href="/chat/control/action/edit/id/'.$Row['id'].'"><span id="edit-red" style="margin-top:-5px"></span></a></li></ul></li></ul& gt;';
//Настройка редактирования комментариев.
if ($Row['id'] == $_SESSION['COMMENTS_EDIT'])
$Row['message'] = '<form method="POST" action="/chat/control" name="form">
<textarea name="text" placeholder="Текст сообщения" maxlength="350" style="width:154px;height:5em;margin:2px" id="comment" onkeypress="return isNotMax(event)" required>'.$Row['message'].'</textarea>
<br/><center><input type="submit" name="save" value="Сохранить" /> <input type="submit" name="cancel" value="Отменить" /></center></form>';
// ---
// ББ-КОДЫ
$smail = array("","", "","", "","", "","");
$grafic = array("<b>","</b>", "<i>","</i>", "<s>","</s>", "<u>","</u>");
$Row['message'] = str_replace($smail, $grafic, $Row['message']);
//---
echo '<div id="mess">'.$Row['message'].'</div>';
}
//TEXTAREA №1
echo '<form method="POST" action="/chat/add" name="forma">
<textarea name="text" id="comment" maxlength="350" onkeypress="return isNotMax(event)" required></textarea>
<input type="submit" name="enter" id="chbutton" value="GO" />
<input type="hidden" name="user_id" value="'.$_SESSION['USER_ID'].'">
</form>
// --
//TEXTAREA №2
echo '<form method="POST" action="/chat/add" name="forma">
<textarea name="text" id="comment" maxlength="350" onkeypress="return isNotMax(event)" required></textarea>
<input type="submit" name="enter" id="chbutton" value="GO" />
</form>
// --
<!--Блок ББ-кодов-->
<a href="javascript:" onclick="tag (document.getElementById (`comment`),``,``)"><font style="font-family:Verdana">Жирный текст</font></a>
<br/><a href="javascript:" onclick="tag (document.getElementById (`comment`),``,``)"><i>Наклонный текст</i></a>
<br/><a href="javascript:" onclick="tag (document.getElementById (`comment`),``,``)"><s>Зачеркнутый текст</s></a>
<br/><a href="javascript:" onclick="tag (document.getElementById (`comment`),``,``)"><u>Подчеркнутый текст</u></a>
';
?>
Скрипт смайлов:
Свернутый текст
function x () {return;}
function FocusText() {
document.forma.text.focus();
document.forma.text.select();
return true; }
function DoSmilie(addSmilie) {
var revisedmsgage;
var currentmsgage = document.forma.text.value;
revisedmsgage = currentmsgage+addSmilie;
document.forma.text.value=revisedmsgage;
document.forma.text.focus();
return;
}
function tag (TXT, startTag, endTag)
{
TXT.focus ();
if (document.selection) with (document.selection.createRange ())
{
var t = text; text = startTag + text + endTag;
if (!t.length) moveEnd (`character`, endTag.length * (-1)); select ();
}
else if (TXT.selectionStart >= 0) with (TXT)
{
var sT = scrollTop, sL = scrollLeft, t = value,
stS = selectionStart, leS = selectionEnd - stS,
w = (startTag + t.substr (stS, leS) + endTag).length;
value = t.substr (0, stS) + startTag + t.substr (stS, leS) + endTag + t.substr (stS + leS);
if (leS) selectionStart = selectionEnd = stS + w;
else selectionStart = selectionEnd = stS + startTag.length;
scrollTop = sT, scrollLeft = sL;
}
else TXT.value += startTag + endTag;
}
function DoPrompt(action) { var revisedmsgage; var currentmsgage = document.forma.qmsgage.value; }