Solved

Remove line breaks from textarea

Posted on 2010-09-14
5
740 Views
Last Modified: 2012-05-10
Is there a way to remove the linke breaks which appear in internet explorer after the output of the textarea?
<textarea cols="90" rows="6" name="content"><!- START --><iframe width="400" height="250" src="http://maps.google.com/maps/api/staticmap?center=<?php echo $attorneysStuff['bizAddr'];?>,<?php echo $attorneysStuff['bizCity'];?>,<?php echo $attorneysStuff['bizState'];?>&zoom=14&size=400x250&maptype=roadmap&markers=color:blue|label:S|<?php echo $attorneysStuff['bizAddr'];?>,<?php echo $attorneysStuff['bizCity'];?>,<?php echo $attorneysStuff['bizState'];?>&sensor=false"></iframe><br><a href="<?php  session_start();echo $_SESSION['bizurl']; ?>"><?php echo $attorneysStuff['bizName'];?></a><!- END -->
</textarea>

Open in new window

0
Comment
Question by:seopti
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 14

Expert Comment

by:shobinsun
ID: 33679226
0
 
LVL 40

Expert Comment

by:gurvinder372
ID: 33679227
If you are looking for how to remove line breaks using javascript, then
http://www.textfixer.com/tutorials/javascript-line-breaks.php

document.getElementById("textArea1").value will give you the value of TextArea given that its id is textArea1.
0
 
LVL 5

Accepted Solution

by:
bupper earned 500 total points
ID: 33679330
Here is a good little script you can use for a PHP function (put this in your file before your textarea):
<?php
function stripJunk ($value) {
    // this will trim junk from strings, such as TAB, NEWLINE, NULL, and more
    $value = str_replace(str_split("\x0b\t\x00\r\n\\"), '', $value);
   
    // strip whitespace and other trash from beginning/end
    $value = trim($value);
   
    return $value;
}
?>

Then when you are outputting the data to your textarea, use something like:
<?php echo stripJunk($attorneysStuff['bizAddr']);?>
0
 
LVL 7

Expert Comment

by:Vimal DM
ID: 33684431
Hai,

1) When storing DB itself use "nl2br" PHP function to store the text

2) When there is display can just print the html code or use the "str_replace" function to replace the break tag.


Thanks
0
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 33690759
You can use trim() to remove whitespace from the front and back of a string.
http://us3.php.net/manual/en/function.trim.php

You can use the REGEX example#5 shown here to strip excessive whitespace.
http://us3.php.net/manual/en/function.preg-replace.php

I would escape the cleaned-up string and store it in the data base.  When I am ready to produce output to the browser, I would take the string out of the data base, run it through htmlentities() to prevent bad stuff going to a client machine, and then use nl2br() to produce the appropriate line spacing.

HTH, ~Ray
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question