MinusMyThoughts Posted September 24, 2006 Share Posted September 24, 2006 If I want to take the input from a form, such as this: <textarea rows="15" cols="20" name="newsBody"></textarea> and keep the input formatted in a manner determined by the user (i.e. keeping line breaks), what are my steps?Is there a simple HTML answer, or am I getting into something a little more advanced?Thanks so much!love,JasonAlso, sorry about the "<textarea>" in the title. I thought I needed that. Apparently I'm a worrier. Link to comment Share on other sites More sharing options...
holmedwa04 Posted September 24, 2006 Share Posted September 24, 2006 I dont really understand you, you can set the font? Link to comment Share on other sites More sharing options...
MinusMyThoughts Posted September 24, 2006 Author Share Posted September 24, 2006 I dont really understand you, you can set the font?Sorry. Let me clarify:Say the user inputs text as:"Hello,This is my text. I hope you like it.Sincerely,User"When I go to retrieve that information and display it somewhere else (I'll be using PHP for this portion of things), it displays as:"Hello, This is my text. I hope you like it. Sincerely, User"How can I get all my line breaks to include themselves when I submit the text in my text area?Hopefully this makes a little more sense...Jason Link to comment Share on other sites More sharing options...
holmedwa04 Posted September 24, 2006 Share Posted September 24, 2006 Oh sorry, im not sure about that, I thought you meant thing like font and color etc.Sorry to be of no help Link to comment Share on other sites More sharing options...
murfitUK Posted September 24, 2006 Share Posted September 24, 2006 If using php try this. If you put the text input into a variable $text then print it on screen using:print nl2br($text);which will print it out with the line breaks. Its a start but you will run into problems if the user starts placing single and double quote marks into the text so you will also need to take that into account. Link to comment Share on other sites More sharing options...
MinusMyThoughts Posted September 24, 2006 Author Share Posted September 24, 2006 you will run into problems if the user starts placing single and double quote marks into the text so you will also need to take that into account.Thanks!I'll check into safeguarding against the quotes. You've been a great help!Jason Link to comment Share on other sites More sharing options...
MinusMyThoughts Posted September 24, 2006 Author Share Posted September 24, 2006 I just tried echo StripSlashes(nl2br($text)); and it worked great. Is that bad practice?Jason Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now