f



replacing text for use in a text area...

Hi Gurus

I have a PHP page that allows a user to preview an email and then send it
if(s)he is happy with it.

Otherwise, they can click on an edit button and edit the text of the
message.  The text is then shown in a textarea element.

While in situation A (the preview), a bit of formatting is useful (e.g
<BR>), all of this formatting is a nuisance in the textarea.

Basically, I would like to do the following:
a. replace <BR> with a line break for the textarea
b. get rid of double spaces and tabs before the text is loaded in the
textarea
c. put the <BR>s back in when the user is finished with editing the message.

Is there a way to do this?

TIA

- Nicolaas



0
access (386)
1/10/2005 9:33:35 AM
comp.lang.php 32646 articles. 0 followers. Post Follow

5 Replies
886 Views

Similar Articles

[PageSpeed] 35

WindAndWaves wrote:

> Hi Gurus

Hi,

I am no guru. :P

> 
> I have a PHP page that allows a user to preview an email and then send it
> if(s)he is happy with it.
> 
> Otherwise, they can click on an edit button and edit the text of the
> message.  The text is then shown in a textarea element.
> 
> While in situation A (the preview), a bit of formatting is useful (e.g
> <BR>), all of this formatting is a nuisance in the textarea.
> 
> Basically, I would like to do the following:
> a. replace <BR> with a line break for the textarea

Suppose $content contains the htmlformatted body of the email:

$content = str_replace("<br>","\n",$content);

> b. get rid of double spaces and tabs before the text is loaded in the
> textarea

Bad idea I think.
You are changing the makeup somebody used.
     eg this
                or this

But if you want to: use the same str_replace to find tabs.
Write a little routine to remove more than 1 space.

> c. put the <BR>s back in when the user is finished with editing the
> message.

$content = str_replace("\n","<br>",$content);

> 
> Is there a way to do this?
> 
> TIA
> 
> - Nicolaas


Regards,
Erwin Moller
0
1/10/2005 10:41:45 AM
Suppose you have the text in the $content variable

a.$content=br2nl($content);

b. trim($content). also for trimming the spaces, tabs in the left side
you can use ltrim, same for the right side where you can use rtrim. The
following characters will be removed from the beginning&end of the
content:

" " (ASCII 32 (0x20)), an ordinary space.
"\t" (ASCII 9 (0x09)), a tab.
"\n" (ASCII 10 (0x0A)), a new line (line feed).
"\r" (ASCII 13 (0x0D)), a carriage return.
"\0" (ASCII 0 (0x00)), the NUL-byte.
"\x0B" (ASCII 11 (0x0B)), a vertical tab.
c. $content=nl2br($content);

Hope this helps.
Clau

0
claudel1 (8)
1/10/2005 11:38:18 AM
I noticed that Message-ID: <i1sEd.6581$mo2.446301@news.xtra.co.nz> from
WindAndWaves contained the following:

>I have a PHP page that allows a user to preview an email and then send it
>if(s)he is happy with it.
>
>Otherwise, they can click on an edit button and edit the text of the
>message.  The text is then shown in a textarea element.
>
>While in situation A (the preview), a bit of formatting is useful (e.g
><BR>), all of this formatting is a nuisance in the textarea.

Does that mean you intend to send html email?

If not (which I recommend) simply enclose the preview with <pre></pre>
tags and leave all line breaks and tabs as they are.
-- 
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
0
bl4176 (40)
1/11/2005 4:28:06 PM
"Geoff Berrow" <bl@ckdog.co.uk> wrote in message
news:1iv7u0ttnvvf2d81cr3k6tq45clu2pbokp@4ax.com...
> I noticed that Message-ID: <i1sEd.6581$mo2.446301@news.xtra.co.nz> from
> WindAndWaves contained the following:
>
> >I have a PHP page that allows a user to preview an email and then send it
> >if(s)he is happy with it.
> >
> >Otherwise, they can click on an edit button and edit the text of the
> >message.  The text is then shown in a textarea element.
> >
> >While in situation A (the preview), a bit of formatting is useful (e.g
> ><BR>), all of this formatting is a nuisance in the textarea.
>
> Does that mean you intend to send html email?
>
> If not (which I recommend) simply enclose the preview with <pre></pre>
> tags and leave all line breaks and tabs as they are.

Hi Geoff

Good point. Thank you, yes, I am sending HTML email (I think - I have taken
over someone else his site).  Let me have a look into this.... perhaps we
can change it to a text only email - although the email only contains a
couple of <BR>s....

Thank you


- Nicolaas


0
access (386)
1/11/2005 6:18:30 PM
WindAndWaves wrote:
> Hi Gurus
> 
> I have a PHP page that allows a user to preview an email and then send it
> if(s)he is happy with it.
> 
> Otherwise, they can click on an edit button and edit the text of the
> message.  The text is then shown in a textarea element.
> 
> While in situation A (the preview), a bit of formatting is useful (e.g
> <BR>), all of this formatting is a nuisance in the textarea.
> 
> Basically, I would like to do the following:
> a. replace <BR> with a line break for the textarea
> b. get rid of double spaces and tabs before the text is loaded in the
> textarea
> c. put the <BR>s back in when the user is finished with editing the message.
> 
> Is there a way to do this?
> 
> TIA
> 
> - Nicolaas
> 
> 
> 
May be a little off-topic, but you might want to look at HTMLArea for 
_really_ fancy textareas. It is very cool Javascript that adds a full 
gui editor toolbar to textareas:

http://www.dynarch.com/projects/htmlarea/

Sacs
0
1/11/2005 8:44:45 PM
Reply:

Similar Artilces:

PHP - using mail() and unicode text
I have the following problem. On a website there's a (simple) feedback form. This is used also by Polish visitors who (of course) type Polish text using special characters. However, when I receive the text in my mailbox, all special characters have been turned into mess...... For example: "wsp�lprace" is turned into "współprace". It seems PHP is handling the Unicode-8 strings quite well (when I 'echo' the strings on the site, I see the text correctly), until the point that it is send by using mail(). Is this a server configuration issue? Or something el...

text-text
Wondering how what I input to my UTF-8 terminal gets passed along through my patched [1] trn ... Cyrillic: А Б В Г Д Е Ж З И Й К Л М Н О П а б в г д е ж з и й к л м н о п IPA: ᴀ ᴁ ᴂ ᴃ ᴄ ᴅ ᴆ ᴇ ᴈ ᴉ ᴊ ᴋ ᴌ ᴍ ᴎ ᴏ ɀ Ɂ ɂ Ƀ Ʉ Ʌ Ɇ ɇ Ɉ ɉ Ɋ ɋ Ɍ ɍ Ɏ ɏ [1] https://groups.google.com/d/msg/comp.sys.raspberry-pi/7Z37Hdrm0DM/6aqD-reXFzAJ ...

text + text
What is "text + text" supposed to do right now? It doesn't seem very useful to me. What about making "text + text" as an equivalent for "text || text"? Most strongly-typed programming languages do this. And MS SQL Server too, I think (CMIIW). -- dave ---------------------------(end of broadcast)--------------------------- TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org Am Freitag, 8. Oktober 2004 12:57 schrieb David Garamond: > What is "text + text" supposed to do right now? Nothing. > What a...

Can I use SAS to search and replace a piece of text in, say, 1000 text files?
How can I use SAS to search and replace a piece of text in, say, 1000 text files? Thanks for letting me know. Toby ...

Checkbox to load text into text area
I'm looking to create an online practice exam that mimics this one: http://www.castleworldwide.com/tds_v5/hybrid/asp/hybrid_exam_driver.asp Does anyone have any ideas on how to create checkboxes that load the responses without loading a new page? Any help would be appreciated. On Jan 31, 8:08 pm, Andy Burghardt <aburgh...@gmail.com> wrote: > I'm looking to create an online practice exam that mimics this one:http://www.castleworldwide.com/tds_v5/hybrid/asp/hybrid_exam_driver.asp DB is down as of now. > Does anyone have any ideas on how to create checkboxes that load the...

Replace text with image in text widget
I'm trying to replace an emoticon with an actual image in a text widget. I know I'm not doing this correctly: the sample code below inserts two images randomly and seems to garble the text in other ways. The idea is to have two emoticons (one on each line) and replace them with an image, nothing more. Can anyone take a look and suggest how I might get this to work? Thanks. --- SPfHZvvOGvfQEvfGdvjQE/rNMfrOMfrNPfvQHfzQHfjQLfrNRvjQL/vRJfzRJvrOWvbMh/3VHPfM h/3WHPzVMP7XF/zVMfrPdv7YGP7YG/7YHPzWPPzWPfvUVP7ZHf7ZIPvWVf7aJv7aJ/7bJv7bM/7b NP7cLf7dMPvXeP7dNvrVlv7eOPrWlvvaevrYmP7gRP7gRf7gRv7i...

Deleting selected text from text area
I was wondering if anyone could help. I'm trying to find how to delete text from a selected text Area. I'm a beginner in Java Netbeans. So go easy! This is what I tried but its not happening. int start = 0, end = 1; while ( start < end ) { start = SpeechText.getSelectionStart(); end = SpeechText.getSelectionEnd(); if ( start != end ) remove( SpeechText.getText() ); } tom79l@googlemail.com wrote: > I was wondering if anyone could help. I'm trying to find how to > delete text from a selected text Area. > > I'm a beginn...

Replacing text in a text file with VB6
Hi all, I'm trying to figure out how to replace text in a text file with a new string. The replace function seems to be the way to go, but I can't get it to work right. The program is a time clock for employees to punch in and out at a business. It uses ADOX for its database and creates a separate text file for each employee which the clock in and clock out timestamps are written to. The top 3 lines of each file containe 1. The employee's name, 2. His or her SSN, and 3. His or her employee number. If an employee's name or SSN changes, I have no problem updatin...

replace text in IFRAME using innerHTML.replace(...) possible?
I'd like to load a document into an iframe, and allow the user to replace fields like %Author%, %Title% etc. with text they enter into text boxes. I can do it if I use spans with unique ID's for each text entry I'd like to change, but I'd like to avoid that if there's a simpler approach. So far I can't get a straight replace to work on the iframe innerHTML: document.frames['iframe1'].document.body.innerHTML.replace(oldtext,newtext); Any suggestions? TIA, Mike mscir wrote: > I'd like to load a document into an iframe, and allow the user to > ...

Half a text area with text-indent not on purpose.
Hi. I am new here (and new in webdesign), and hope to get a little help. I am also foreigner, so please excuse me, if I spell a little funny, or use funny words :) www.marselisborgapotek.frac.dk www.marselisborgapotek.frac.dk/css/style.css the class .textarea has a text-indent half way down, which I cannot understand. It is not much, so look carefully (it is untill the line "til den almindelige hud..." It only happens in IE (of course!) Does anyone have a clue why that happens Thanks for helping Anne On 14 Oct 2005 14:43:07 -0700, Anne wrote: > Hi. &...

Font size in text Field and text Area
I am using swing. I want to reduce the size of the font in text areas and text fields to fit more in. Is there an easy to do this?? Mark On Sun, 14 Sep 2003 23:42:15 GMT, "Mark and Ingrid Nugent" <nugget@in.com.au> wrote or quoted : >I am using swing. I want to reduce the size of the font in text areas and >text fields to fit more in. Is there an easy to do this?? see http://mindprod.com/jgloss/font.html You can setFont individually, or change the LAF. -- Canadian Mind Products, Roedy Green. Coaching, problem solving, economical contract programming. See http://m...

How to display text messages in a scrolling text area?
To display text messages (as - for example - in a window with log messages) in a scrolling text area, there are several Swing components I am aware of: http://download.java.net/jdk7/docs/api/javax/swing/JTextArea.html http://download.java.net/jdk7/docs/api/javax/swing/JTextPane.html http://download.java.net/jdk7/docs/api/javax/swing/JEditorPane.html I might want to subclass one of them for my �log area�. While I only think of plain text output now, more features, such as different typefaces or text colors might come in handy later. I also might want to use one of them in teach...

Using Control-a to select all text in a text widget
I'm having a difficult time binding Control-a so it selects all the text in a widget just like the default Control-/ binding does. I've tried: ..t bind <Control-a> [.t bind <Control-/>] But [.t bind <Control-/>] returns nothing. If I do: ..t bind <Control-/> {puts "Selecting all"} ..t bind <Control-a> [.t bind <Control-/>] When I hit Control-/ I get at the prompt "Selecting all" and all the text is selected. But when I hit Control-a all I get is the "Selecting all" at the prompt and no text is selected. I've als...

replace instances of text on page with image or other text?
Hello, I need to look through the text on a page and replace certain words with an image or other word something like: read document find all instances of the word "blah" change all instances of the word "blah" to <img src="MyPicture.jpg" > (jeez, I don't get why computers cant just read english!<G>) and, no, I cant just change the page with 'find/replace' in notepad. -- thanks, juglesh B>{)} "juglesh" <juglesh@nospamRadioKDUG.com> wrote in message news:Sj_xd.302269$R05.120039@attbi_s53... > Hell...

Web resources about - replacing text for use in a text area... - comp.lang.php

Facebook Tests Replacing Keyword Ad Targeting With Broad Category Targeting
Facebook is testing a major functionality change for its self-serve performance ad tool that would replace the specific Like keyword targeting ...

The Dangers of Replacing Coil Springs on Your Vehicle - Bonus Clip - YouTube
In this episode of Saturday Mechanic bonus clip, Ben and Russ show what happens when a coil spring compressor fails. Subscribe today for more! ...

School apologises for taking cane off blind boy and replacing it with pool noodle
A primary school has apologised for taking away the cane of an eight-year-old blind boy and replacing it swimming pool noddle as a form of punishment. ...

Federation Centres stuns market by replacing CEO Steven Sewell with Angus McNaughton effective immediately ...
Retail landlord Federation Centres has surprised the market with the&nbsp;appointment of&nbsp;former Novion Property's Angus McNaughton as the ...

Replacing China's broken economic gauge
As Chinese growth shifts away from its reliance on heavy industry, we need a new index to the track the ups and downs of the economy.

Inner south residents worried about high-rises replacing public housing flats
Residents say the&nbsp;government&nbsp;is over-developing its inner south blocks to maximise their sale value.

Apache Software Foundation unveils Hadoop 2, replacing MapReduce with YARN
The Apache Software Foundation unveiled its latest release of its open source data processing program, Hadoop 2. It runs multiple applications ...

Australia spends $110 million a year replacing lost coins
Australians lose 255 million coins every year - down the back of our couches, taken overseas in the pockets of tourists and stuck to footpaths. ...

Tweets Replacing Resumes - Twitter Becomes Job-Hunting Tool
Forget paper resumes, your next job could hang on a 140-letter tweet.

A case of one bad government replacing another
THERE is a widening gap between the sort of government a Tony Abbott-led Coalition will need to become to steer the nation successfully in the ...

Resources last updated: 1/28/2016 3:10:44 PM