MDanz Posted June 21, 2010 Share Posted June 21, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/205412-textarea-probelm-with-htmlentities/ Share on other sites More sharing options...
phpchamps Posted June 21, 2010 Share Posted June 21, 2010 its displaying perfectly fine at my place.. Quote Link to comment https://forums.phpfreaks.com/topic/205412-textarea-probelm-with-htmlentities/#findComment-1074975 Share on other sites More sharing options...
MDanz Posted June 21, 2010 Author Share Posted June 21, 2010 its displaying perfectly fine at my place.. try this code... it doesn't work. put your mouseover "test". <?php $sumz= "car1>>car2"; $textsearch = array('<','>'); $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> Quote Link to comment https://forums.phpfreaks.com/topic/205412-textarea-probelm-with-htmlentities/#findComment-1075006 Share on other sites More sharing options...
PFMaBiSmAd Posted June 21, 2010 Share Posted June 21, 2010 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> Quote Link to comment https://forums.phpfreaks.com/topic/205412-textarea-probelm-with-htmlentities/#findComment-1075035 Share on other sites More sharing options...
PFMaBiSmAd Posted June 21, 2010 Share Posted June 21, 2010 And since this problem concerns the DOM in the browser, how it is processed, and php has nothing to do with the problem, moving thread to the javascript forum section... Quote Link to comment https://forums.phpfreaks.com/topic/205412-textarea-probelm-with-htmlentities/#findComment-1075047 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.