SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot
    Join Date
    Jul 2004
    Location
    NC
    Posts
    194
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    holding carriage returns and newlines in a textarea

    Hello,

    I'm having problem w/ a textarea. I lose the newlines and carriage returns in a textarea when I refresh the page from another frameset, I lose all the newlines and carriage returns and the text is combined on one line.

    Here's more details on what I'm trying to do. I'm working on an email program that consist of 2 frames - 1 we'll call the address frame and one we'll call the mail frame.

    When the user hits a submit button on the address frame, it reloads the mail frame and adds the chosen addresses in the "Recipient" textfield.

    If there is text in the address frame textarea it will lose it's formatting and put all text on one line.

    I've tried throwing the textarea text from the mail frame to a hidden field in the address frame and then back to the mail frame via javascript but it still didn't work.

    Does this make sense?

  2. #2
    SitePoint Guru Galo's Avatar
    Join Date
    May 2005
    Location
    Holland!
    Posts
    852
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by clem_c_rock
    Hello,

    I'm having problem w/ a textarea. I lose the newlines and carriage returns in a textarea when I refresh the page from another frameset, I lose all the newlines and carriage returns and the text is combined on one line.

    Here's more details on what I'm trying to do. I'm working on an email program that consist of 2 frames - 1 we'll call the address frame and one we'll call the mail frame.

    When the user hits a submit button on the address frame, it reloads the mail frame and adds the chosen addresses in the "Recipient" textfield.

    If there is text in the address frame textarea it will lose it's formatting and put all text on one line.

    I've tried throwing the textarea text from the mail frame to a hidden field in the address frame and then back to the mail frame via javascript but it still didn't work.

    Does this make sense?

    Sence is something else though but i think your problem is the fact that you loose your /n and /r through parsing, try to use htmlspecialchars or nl2br which converts /n to a <br> tag, i think php offers a function to convert /t to 3 spaces as well, you could write a common function which does that though.

    btw, if nothing else works for u you can always serialize your string and unserialise it when needed, this will encrypt the string and remains the tabs and newlines.
    hope this helps
    Galo

  3. #3
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,806
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    Further to Galo's suggestion is:
    Store the text data in a session, then display the session variable in the textarea using the nl2br() function.
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  4. #4
    SitePoint Zealot
    Join Date
    Jul 2004
    Location
    NC
    Posts
    194
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think the serialize and the session ideas are both great ideas - going to work on it right now.

    thanks!


Bookmarks

Posting Permissions

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