Jump to content

Recommended Posts

In the textarea it displays this

 

car1 >>car2 when it should display car1>>car2

 

this is my code, here's what i tried to resolve it...

 

$sumz= "car1>>car2";

$textsearch = array('<','>');
$textreplace = array ('<','>');
$textareatext = "$sumz";


			echo "<div style='display:none;' id='$number'>".str_replace($textsearch,$textreplace,htmlentities($textareatext))."</div>";

 

it still displays car1 >>car2

 

:confused:

 

Link to comment
https://forums.phpfreaks.com/topic/205412-textarea-probelm-with-htmlentities/
Share on other sites

its displaying perfectly fine at my place..

 

try this code... it doesn't work.  put your mouseover "test".

 

<?php
$sumz= "car1>>car2";

$textsearch = array('&lt;','&gt;');
$textreplace = array ('<','>');
$textareatext = "$sumz";


            echo "<div style='display:none;' id='1'>".str_replace($textsearch,$textreplace,htmlentities($textareatext))."</div>";
		echo "<table><tr><td onmouseover='Test(1);'>test </td></tr></table>";

echo "<br /><br /><textarea name='reply' id='reply' style='color: #000000; overflow: hidden; font-size:15px; height:52px; width:500px; text-align: left' readonly='readonly'  >test</textarea>";
?>

<script type="text/javascript">
function Test(number) {
var newtext = document.getElementById(number).innerHTML;
   document.getElementById('reply').value = newtext;
   }
</script>

Now that you have bothered to show what you are doing and what your code really is (you could have solved this 2 days a go in your original thread on this problem), here are a couple of solutions - http://www.webdeveloper.com/forum/archive/index.php/t-136026.html

 

Your str_replace() is not doing anything because the strings you are searching for don't exist (and if they did, outputting < and > would break the HTML) -

<?php
$sumz= "car1>>car2";

$textareatext = $sumz;

            echo "<div style='display:none;' id='1'>". htmlentities($textareatext) ."</div>";
         echo "<table><tr><td onmouseover='Test(1);'>test </td></tr></table>";

echo "<br /><br /><textarea name='reply' id='reply' style='color: #000000; overflow: hidden; font-size:15px; height:52px; width:500px; text-align: left' readonly='readonly'  >test</textarea>";
?>

<script type="text/javascript">

function get_ents(str){
var temp=document.createElement("pre");
temp.innerHTML=str;
return temp.firstChild.nodeValue;
}

function Test(number) {
var newtext = document.getElementById(number).innerHTML;
   document.getElementById('reply').value = get_ents(newtext);
   }
</script>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.