473,396 Members | 1,995 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Multiline Textbox Problems

Hey all, I'm having some trouble. On a page, I've got a multiline text
box. When I enter :

a
b
c
d

and hit submit (sending to my post.php page) and from post.php, echo
$_POST["info"] if shows up as a b c d. No carrige returns show. My
questions is... how can I do this? I know it's possible because I've
seen demonstrations, but can't seem to figure out how to do it.

Thanks,
IWP506

Jul 17 '05 #1
13 6055

On 18-May-2005, IW****@gmail.com wrote:
Hey all, I'm having some trouble. On a page, I've got a multiline text
box. When I enter :

a
b
c
d

and hit submit (sending to my post.php page) and from post.php, echo
$_POST["info"] if shows up as a b c d. No carrige returns show. My
questions is... how can I do this? I know it's possible because I've
seen demonstrations, but can't seem to figure out how to do it.


The problem is the browser treats newlines as white space. Change \n to <br>
( str_replace("\n",'<br>',$txt) ) before you echo it to the browser.

--
Tom Thackrey
www.creative-light.com
tom (at) creative (dash) light (dot) com
do NOT send email to ja*********@willglen.net (it's reserved for spammers)
Jul 17 '05 #2
Użytkownik "Tom Thackrey" <us***********@nospam.com> napisał w wiadomo¶ci
news:Ee*******************@newssvr14.news.prodigy. com...
The problem is the browser treats newlines as white space. Change \n to <br> ( str_replace("\n",'<br>',$txt) ) before you echo it to the browser.

there is a function nl2br() ;-)
also you can print tag <pre> before $txt

Jul 17 '05 #3
thanks! I'll give that a shot

-PulsarSL

Jul 17 '05 #4
IW****@gmail.com wrote:
: Hey all, I'm having some trouble. On a page, I've got a multiline text
: box. When I enter :

: a
: b
: c
: d

: and hit submit (sending to my post.php page) and from post.php, echo
: $_POST["info"] if shows up as a b c d. No carrige returns show. My
: questions is... how can I do this? I know it's possible because I've
: seen demonstrations, but can't seem to figure out how to do it.

One issue is that the HTML in the form makes a difference to what you get
back.

The edit field can wrap the lines to display them so they look like
separate lines even if they are still on the same "physical" line (like
what a word processor does).

So, look up the various attributes for the HTML FORM input element you are
using, and try the various options to see what diference they make.
--

This space not for rent.
Jul 17 '05 #5
Hm... doesn't seem to be working. here's my code, It echos nothing.

-----

<html>
<body>
<?php
$mynotes="";
if (!($f=fopen("./posts/" . $_POST["password"] . ".txt" ,"r")))
exit("Unable to open file.");
while (!feof($f))
{
$x=fgetc($f);
//echo $x;
$mynotes=$mynotes . $x;
}
str_replace("\n",'<br>',$mynotes);
echo $mynotes;
fclose($f);
?>

Thanks
PulsarSL

Jul 17 '05 #6
OHHH i think i need to do the str_replace before i write the file!
*lightbulb*

(dim lightbulb, but lightbulb)

Jul 17 '05 #7
You could also try using myStr = nl2br(myStr) - this is PHP's built in
function for doing what you are describing.

--
Rick - www.e-connected.com/functional/

Jul 17 '05 #8
You could also try using myStr = nl2br(myStr) - this is PHP's built in
function for doing what you are describing.

--
Rick - www.e-connected.com/

Jul 17 '05 #9
Thanks, the n12br function was just what I was looking for.

-PulsarSL

Jul 17 '05 #10
"thehuby" <ri*******@e-connected.com> wrote in message news:<11*********************@f14g2000cwb.googlegr oups.com>...
You could also try using myStr = nl2br(myStr) - this is PHP's built in
function for doing what you are describing.


I am using the textarea to enter the data from the form into the
database. In the textarea, the data was entered as (new line and
spaces)

Welcome
My web site

Hello everyone,
In this site you will find some php code.
The data was saved in the database field exactly the same.

Now in the edit form, the data was again displayed exactly the same in
the textarea exactly the same. But when the data was echoed in the php
code, the data was displyed without the spaces that was inserted. The
variabled that was echoed in both textare (at edit time) and at
displaying come from the database.
Welcome
My web site

Hello everyone,
In this site you will find some php code.

Now can anyone help with the problem, so that spaces are also
displayed.
Jul 17 '05 #11
manish wrote:
"thehuby" <ri*******@e-connected.com> wrote in message news:<11*********************@f14g2000cwb.googlegr oups.com>...
You could also try using myStr = nl2br(myStr) - this is PHP's built in
function for doing what you are describing.

I am using the textarea to enter the data from the form into the
database. In the textarea, the data was entered as (new line and
spaces)

Welcome
My web site

Hello everyone,
In this site you will find some php code.
The data was saved in the database field exactly the same.

Now in the edit form, the data was again displayed exactly the same in
the textarea exactly the same. But when the data was echoed in the php
code, the data was displyed without the spaces that was inserted. The
variabled that was echoed in both textare (at edit time) and at
displaying come from the database.
Welcome
My web site

Hello everyone,
In this site you will find some php code.

Now can anyone help with the problem, so that spaces are also
displayed.


They're there - look at your source. The HTML parser will remove out
extra white space.

You can surround the output with <pare></pre> or convert the extra
spaces to &nbsp;

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jul 17 '05 #12
"manish" <ye*********@gmail.com> wrote in message
news:18**************************@posting.google.c om...
"thehuby" <ri*******@e-connected.com> wrote in message
news:<11*********************@f14g2000cwb.googlegr oups.com>...
Now in the edit form, the data was again displayed exactly the same in
the textarea exactly the same. But when the data was echoed in the php
code, the data was displyed without the spaces that was inserted. The
variabled that was echoed in both textare (at edit time) and at
displaying come from the database.
Welcome
My web site

Hello everyone,
In this site you will find some php code.

Now can anyone help with the problem, so that spaces are also
displayed.


You really have basically two choices, far as I can tell - the problem is
with HTML, not PHP.

Either replace all spaces in the field with '&nbsp;' or wrap the entire
output in <pre></pre> tags
Jul 17 '05 #13
Having <pre></pre> tag doen't give the same number of spaces that was inserted.

Howerever using str_replace works prefectly

$description = str_replace(" ", "&nbsp;", $description);
echo nl2br($description);

Thanks.
Jerry Stuckle <js*******@attglobal.net> wrote in message news:<2b********************@comcast.com>...
manish wrote:
"thehuby" <ri*******@e-connected.com> wrote in message news:<11*********************@f14g2000cwb.googlegr oups.com>...
You could also try using myStr = nl2br(myStr) - this is PHP's built in
function for doing what you are describing.

I am using the textarea to enter the data from the form into the
database. In the textarea, the data was entered as (new line and
spaces)

Welcome
My web site

Hello everyone,
In this site you will find some php code.
The data was saved in the database field exactly the same.

Now in the edit form, the data was again displayed exactly the same in
the textarea exactly the same. But when the data was echoed in the php
code, the data was displyed without the spaces that was inserted. The
variabled that was echoed in both textare (at edit time) and at
displaying come from the database.
Welcome
My web site

Hello everyone,
In this site you will find some php code.

Now can anyone help with the problem, so that spaces are also
displayed.


They're there - look at your source. The HTML parser will remove out
extra white space.

You can surround the output with <pare></pre> or convert the extra
spaces to &nbsp;

Jul 17 '05 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Suresh Kumaran | last post by:
Hi All, Does anybody know the sytax in VB.NET to write the contents of a multiline text box to a text file? Appreciate help. Suresh
4
by: Michael C | last post by:
Hi all, I'm trying to add lines to a multiline textbox. Here's what I'd like to end up with in the textbox (as an example): Line1 Line2 Line3 I've tried a couple of methods but nothing...
7
by: Joel Finkel | last post by:
Folks, I have a form that has several TextBoxes, some of which have the TextMode set to MultiLine. Each is pre-loaded with data from a database. The user is allowed to modify each entry. The...
2
by: Enzo Marinelli | last post by:
Hello everyone I have a MultiLine TextBox, as follows <asp:TextBo Id="StreetAddress Rows="4 Runat="Server TextMode="MultiLine Width="100%"/
10
by: danthman | last post by:
I have a TextBox set up as follows: <asp:TextBox ID="SubjectTextBox" TextMode="MultiLine" MaxLength="100" Columns="50" Rows="2" Wrap="true" runat="server" />
6
Coldfire
by: Coldfire | last post by:
I am having problems with Maxlength of Multiline "Textbox". I have browsed alot to find the solution. Tons of javascripts have been found but they all deal with <asp:textarea >............. and...
2
by: Mike | last post by:
I am trying to write a little program for my own use using VB2005 express edition. I have a list of peoples names in a file that I read into an array of strings. I am using a multiline textbox to...
7
by: Anil Gupte | last post by:
I have read a lot about getting lines from a multiline textbox in VB.Net. However, I cannot for the life of me figure out how to write to a multiline textbox. Basically, I have created an array of...
4
by: =?Utf-8?B?R2lkaQ==?= | last post by:
Hi, In multiLine textBox, enter moves to the next line, how can i overwrite it, so enter will move to the next control and ctrl + enter will move to the next line? Thanks, Gidi.
2
by: Nathan Sokalski | last post by:
I have a multiline TextBox that I want to display the text used to create a control in an apsx file. I want each of these to be on a separate line in the TextBox. The only way I know of to place...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.