JavaScript | Помогите с js смайлами
<script language="JavaScript" type="text/javascript">
function tag(text1, text2) {
if ((document.selection)) {
document.message.text.focus();
document.message.document.selection.createRange().text = text1+document.message.document.selection.createRange().text+text2;
} else if(document.forms['message'].elements['text'].selectionStart!=undefined) {
var element = document.forms['message'].elements['text'];
var str = element.value;
var start = element.selectionStart;
var length = element.selectionEnd - element.selectionStart;
element.value = str.substr(0, start) + text1 + str.substr(start, length) + text2 + str.substr(start + length);
document.forms['message'].elements['text'].focus();
} else document.message.text.value + text1+text2;
document.forms['message'].elements['text'].focus();}</script>
<script type="text/javascript">
function look(t){
p=document.getElementById(t);
l=document.getElementById("a-"+t);
if(p.style.display=="none"){
l.innerHTML='<img src="/img/smisl.gif" align="center" alt="" height = "20" width = "20"/>';
p.style.display="block";}
else{
l.innerHTML='<img src="/img/smisl.gif" align="center" alt="" height = "20" width = "20"/>';
p.style.display="none";}
}
</script>
<a class="auth" href="javascript:look('text1');" id="a-text1"><img src="/img/smisl.gif" align="center" alt="" height = "20" width = "20"/></a>
<div id="text1" style="display:none; text-align:justify;">
<div style="margin:4px;">
<a href="javascript:tag(':)', '')"><img src="/smiles/smile.gif" alt="*" title="*"/></a>
<a href="javascript:tag('.сердит.', '')"><img src="/smiles/serdit.gif" alt="*" title="*"/></a>
<a href="javascript:tag('.секрет.', '')"><img src="/smiles/secret.gif" alt="*" title="*"/></a>
<a href="javascript:tag('.крут.', '')"><img src="/smiles/o4ki.gif" alt="*" title="*"/></a>
неработают только текст : )
function smiles($text){
$text = trim($text);
$smiles = mysql_query("SELECT * FROM `smile` ORDER BY `id` DESC");
while($smiles2 = mysql_fetch_array($smiles)){
$text = str_replace($smiles2['smile'],' <img src="/smiles/'.$smiles2['name'].'" alt=""/> ',$text);
}
return $text;
}
вот функция