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
    New Coder
    Join Date
    Mar 2009
    Posts
    74
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Textarea Problem

    in my blog site when user write a blog they can write in text area as their will
    that is they can give space, new line any other alignment. but when i post the blog from database in my website i can maintain user newline useng nl2br() function,but the alignment that is apace is lost.every line is started from begining. how could i solve this problem. i am giving here an example.(i used html textarea tag)

    user input:

    hi, i wanna do something with you
    how about you.do you want to share some thing withme


    mysite output:
    hi, i wanna do something with you .
    how about you.do you want to share some thing withme.
    Last edited by deshi2003; 03-12-2009 at 11:00 AM.

  • #2
    Regular Coder
    Join Date
    Jun 2006
    Location
    UK
    Posts
    911
    Thanks
    302
    Thanked 2 Times in 2 Posts
    I suggest you to use a Rich textbox instead.

    A free and open-source WYSIWYG editor can be found on http://www.openwebware.com/


    Thanx

  • #3
    Regular Coder
    Join Date
    Aug 2008
    Location
    Northern Ireland
    Posts
    167
    Thanks
    12
    Thanked 6 Times in 6 Posts
    I am not sure if this will work, but you could try

    PHP Code:
    str_replace('','$nbsp;',$input

  • #4
    Senior Coder Rowsdower!'s Avatar
    Join Date
    Oct 2008
    Location
    Some say it's everything.
    Posts
    2,027
    Thanks
    5
    Thanked 397 Times in 390 Posts
    Quote Originally Posted by deshi2003 View Post
    in my blog site when user write a blog they can write in text area as their will
    that is they can give space, new line any other alignment. but when i post the blog from database in my website i can maintain user newline useng nl2br() function,but the alignment that is apace is lost.every line is started from begining. how could i solve this problem. i am giving here an example.(i used html textarea tag)

    user input:

    hi, i wanna do something with you
    how about you.do you want to share some thing withme


    mysite output:
    hi, i wanna do something with you .
    how about you.do you want to share some thing withme.

    Hello and welcome to the forums! It helps to put this in a "code" block for the forums. That way we can see that you are trying to preserve the whitespace:
    Code:
    user input:
            
        hi, i wanna do something with you 
                        how about you.do you want to share some thing withme
    
    
    mysite output: 
     hi, i wanna do something with you .
     how about you.do you want to share some thing withme.
    As for the HTML output you just need to use white-space:pre; for the style when you present the user's input on the page. This will ensure that the web page displays all of those times that the user pressed the space bar. This way you don't have to mess with your other coding!
    The object of opening the mind, as of opening the mouth, is to shut it again on something solid. –G.K. Chesterton
    See Mediocrity in its Infancy
    It's usually a good idea to start out with this at the VERY TOP of your CSS: * {border:0;margin:0;padding:0;}
    Seek and you shall find... basically:
    validate your markup | view your page cross-browser/cross-platform | free web tutorials | free hosting

  • #5
    New Coder
    Join Date
    Mar 2009
    Posts
    74
    Thanks
    2
    Thanked 0 Times in 0 Posts
    ok, i wanna say that what about htmlencode() or htmldecode()


  •  

    Posting Permissions

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