?
Solved

Remove line breaks from textarea

Posted on 2010-09-14
5
Medium Priority
?
742 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:Gurvinder Pal Singh
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 2000 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 111

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

WordPress Tutorial 3: Plugins, Themes, and Widgets

The three most common changes you will make to your website involve the look (themes), the functionality (plugins), and modular elements (widgets).

In this article we will briefly define each again, and give you directions on how to install them.

Question has a verified solution.

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

Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
Find out what you should include to make the best professional email signature for your organization.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

764 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