Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Sep 2006
    Location
    India Mumbai
    Posts
    248
    Thanks
    13
    Thanked 1 Time in 1 Post

    html tags getting printed in <textarea>

    Hi all,
    i am trying to display the address of the user in a textarea. (using PHPAJAX). i am already displaying the default address in the <textarea> and it works perfect with all breaks and nbsp;'s. But there is an option for the user to change it. i am using PHPAJAX to let the user select the id's from the list and display the address mapped to that ID is displayed in <textarea>.
    the problem is now its displaying the address as below

    Mr. ABC&amp;lt;br&amp;gt;POLAND

    i tried using all possible options like htmlentities() , htmlspecialchars(), nl2br() but all is falling.

    below is my code:


    function main() {
    $Relation_ID = & $this->Relation_ID;

    global $db;
    if ($Relation_ID!="") {

    $Address =(htmlentities(GetRelAddress($Relation_ID)));
    alert($Address);
    aprint ('RelationInfo' , htmlentities($Address));
    }
    } // end


    what should i do?

    Thanks

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Hi, you need to decode the values instead of encoding them. Look into htmlspecialchars_decode and html_entity_decode

    Hope that helps!
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • #3
    Regular Coder
    Join Date
    Sep 2006
    Location
    India Mumbai
    Posts
    248
    Thanks
    13
    Thanked 1 Time in 1 Post
    that isnt helping too. still the same

    Hope i get some help on it

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    What is the code for GetRelAddress, aprint and alert? If the aprint or alert are also using htmlentities or htmlspecialchars you won't get the correct decoding on the given string. Check into those three functions and see if any of them make use of the same.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • #5
    Regular Coder
    Join Date
    Sep 2006
    Location
    India Mumbai
    Posts
    248
    Thanks
    13
    Thanked 1 Time in 1 Post
    Hello Fou-Lu,

    MILLION THANKS TO YOU. you were right!!!! i was already using the htmlentities() in GetRelAddress(). Now i am directly using it and it works PERFECT


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •