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 4 of 4
  1. #1
    Registered User
    Join Date
    Apr 2003
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    showing text captured with a text area input

    hello, i have this problem in a page i get long user text with a input text area box, after that i save it in a Mysql table and later i show that text in a browser, but if the user insert spacen between paragraph it doesnt save them it show the text as a long single line of thex, how can i get this spaces (\n) to be showed as user inserts the text.

  • #2
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts

    I think I know what you mean.

    You could do a javascript replace

    Code:
    document.whatever.textarea.value.replace(/\n/g,'<br />');
    Or PHP replace...

    PHP Code:
    <?php

    ereg_replace
    ("\n",'<br />',$form_value);

    ?>
    Or there is a PHP function that automatically does this.

    PHP Code:
    <?php

    nl2br
    ($form_value);

    ?>
    Hope this helps.

  • #3
    Registered User
    Join Date
    Feb 2003
    Location
    Berkshire, UK
    Posts
    50
    Thanks
    0
    Thanked 0 Times in 0 Posts
    you can also use <pre></pre> for displaying preformatted text. then you could also add some nice css to stop it from looking too out of place.

  • #4
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts

    oh yeah....

    I forgot about that.

    I have never actually used the <pre> tag before, even though I know what it does. Guess thats just me


  •  

    Posting Permissions

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