About the smileys. Very long address in the input field at the smile. Is it possible shorter?

And let's say if you can do so by clicking on the smiley face I have not displayed the address via img and just short form for example the smiley =) , 8)
<form name="chatform" action="javascript:send();" method="post" class="chatform">
<textarea type="text" spellcheck="false" id="mess_to_send" placeholder=""></textarea>
<img src="img/gif/1.gif" onclick="insertSmile('<img src=img/gif/1.gif class=gif>')">

function insertSmile(smile){
 document.chatform.mess_to_send.text += smile;

When I clicked the form gets this:
<img src=img/gif/1.gif class=gif>
Whether it is possible to reduce? lot of excess space in the shape occupies.
April 4th 20 at 12:55
1 answer
April 4th 20 at 12:57
so here you have a string that is inserted in the text

Can replace it by any reduction, but then do not forget to substitute back at the picture before writing to the DB or output.
Well, or use div[contenteditable] instead of textarea.
how can I replace if I have everything I entered in the textarea is contained in a single variable
$mess=$_POST['mess']; and I are already saving to database.
It is necessary to check the contents of this variable using str_replace? - Tito.Hintz commented on April 4th 20 at 13:00
@marjolaine, Yes, replace, regular season or something like that.
As a variant it is possible by JavaScript before sending. - Casper.Kovac commented on April 4th 20 at 13:03
@Yessenia_Flatley, And whether this code is long running I have a 174 and smile at everyone you need to check:
 $mess=str_replace (":)", "<img src='img/gif/1.gif'>", $temp);
$mess=str_replace ("8)", "<img src='img/gif/2.gif'>", $temp);
$mess=str_replace ("=)", "<img src='img/gif/3.gif'>", $temp);
//...171 times - is this normal? and only works with the third row what did I do wrong?
- Tito.Hintz commented on April 4th 20 at 13:06
If search and replace are arrays, then str_replace() uses each value from each array to search and replace on subject.

© https://www.php.net/manual/ru/function.str-replace.php - Casper.Kovac commented on April 4th 20 at 13:09
@Yessenia_Flatley, I figured ATP) everything went as they wanted - Tito.Hintz commented on April 4th 20 at 13:12

Find more questions by tags JavaScript