473,738 Members | 11,192 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

losing leading blank line on posts

Hi. I'm finding that if I have text entered into a
<textarea ...> </textarea> in a form, and that text
has leading blank lines (with no spaces or anything
else), that when I retrieve the entered text, I
lose the leading blank line. Each time it goes through
a post any top-leading blank line is lost. Only one-
if I have several blank lines in a row at the top,
only the first is lost. (If the top blank line has
a single space, it's handled properly).

Is this normal? When I retrieve, would using htmlentities
to this? No other blank lines are effected, whether in
the middle or the end.

I hope there's some way around this. Any help greatly
appreciated,
-dg
Jul 17 '05 #1
12 3286
dan glenn wrote:
Hi. I'm finding that if I have text entered into a
<textarea ...> </textarea> in a form, and that text
has leading blank lines (with no spaces or anything
else), that when I retrieve the entered text, I
lose the leading blank line.


Is it really getting lost? Are you using your browser's presentation
of the data to check this? If so, check the actual data instead.

--
Jock
Jul 17 '05 #2

"John Dunlop" <jo*********@jo hndunlop.info> wrote in message
news:MP******** *************** *@News.Individu al.NET...
dan glenn wrote:
Hi. I'm finding that if I have text entered into a
<textarea ...> </textarea> in a form, and that text
has leading blank lines (with no spaces or anything
else), that when I retrieve the entered text, I
lose the leading blank line.


Is it really getting lost? Are you using your browser's presentation
of the data to check this? If so, check the actual data instead.

--
Jock


Yes, Jock, it seems to really be getting lost. Try the following:

file: testtextarea.ph p
<?php
if (isset($_POST['t_textarea'])) {
$t_textarea = $_POST['t_textarea'];
} else {
$t_textarea = '';
}
echo <<<TESTIT
<html>
<body>
<form action="testtex tarea.php" method="POST">
<textarea wrap="soft" cols=40 rows=12
name="t_textare a">$t_textar ea</textarea>
<p>
<input type="submit" name="woof" value="Post & Reload">
</form>
</body>

TESTIT;
?>

Create the above php file and run it. Put the cursor in the
textarea, hit ENTER around 5 times to create some blank
lines, then type in something like "here's a line". Then
click on the Post & Reload button and watch the line you
typed crawl upwards with each click.

It makes no difference what argument you use for "wrap" in
the textarea tag, either. I tried "soft", "hard", and left
it out altogether. Same deal.

This isn't the end of the world, but it still sucks. Surely
it's not supposed to act this way??? Is there a work-around?

-dg


Jul 17 '05 #3
dan glenn wrote:
Yes, Jock, it seems to really be getting lost.
Well, it's not. Check the *actual* data, not your browser's
presentation of that data.
Try the following: [...]

Create the above php file and run it. Put the cursor in the
textarea, hit ENTER around 5 times to create some blank
lines, then type in something like "here's a line".
Line breaks immediately following start-tags, any start-tag, *must*
be ignored. That means any line breaks after the TEXTAREA start-tag
ought to be ignored. Browsers not doing that are broken. Your
browser is apparently behaving correctly.
It makes no difference what argument you use for "wrap" in
the textarea tag, either.


About the only useful value for that non-standard attribute is "off".

http://www.cs.tut.fi/~jkorpela/forms/textarea.html#impl

(Hmm, another reason why education is far better than bald
recommendations .)

--
Jock
Jul 17 '05 #4
John Dunlop wrote:
Line breaks immediately following start-tags, any start-tag, *must*
be ignored. That means any line breaks after the TEXTAREA start-tag
ought to be ignored.


No it doesn't John! I don't know what I'm saying.

A *single* line break following a start-tag must be ignored.

--
Jock
Jul 17 '05 #5
John Dunlop wrote:
John Dunlop wrote:
Line breaks immediately following start-tags, any start-tag, *must*
be ignored. That means any line breaks after the TEXTAREA start-tag
ought to be ignored.


No it doesn't John! I don't know what I'm saying.

A *single* line break following a start-tag must be ignored.


And, of course, if I'd been awake, I'd've mentioned that what's
happening is every time you submit the form, a line break is getting
ignored. So, effectively, a line disappears each time.

Phew! That was hard work, wunnit? :-)

--
Jock
Jul 17 '05 #6

"John Dunlop" <jo*********@jo hndunlop.info> wrote in message
news:MP******** *************** *@News.Individu al.NET...
John Dunlop wrote:
Line breaks immediately following start-tags, any start-tag, *must*
be ignored. That means any line breaks after the TEXTAREA start-tag
ought to be ignored.


No it doesn't John! I don't know what I'm saying.

A *single* line break following a start-tag must be ignored.

--
Jock


I'm just curious - WHY in all of creation MUST a linebreak immediately
following any start-tag be ignored??? This is not clear to me. First of
all, it doesn't make any sense to be talking about "linebreaks immediately
following a start tag". The <textarea ...> </textarea> tags are in the php
source merely to contain the starting value for the field and define
the size of the input box that the browser will create - the rows and
cols callouts define the size of the "box" that the user can type into.
When the user types in an initial linebreak, he is not typing it in
immediately after any start-tag! There are no tags at all at this point
- just the input fields that were created by tags when the page loaded.
That input box is dead empty when he starts - there's no reason the
initial linebreak should be ignored any more than any initial character,
that I can see.

I just tested my little testtextarea.ph p program in all my browsers,
and I find that in Opera the leading linebreak is NOT lost. Yea Opera!
In IE, NN, and Mozilla, it gets gobbled. Opera is behaving correctly,
the others are in error, in my opinion, as little good as that's worth.

Anyway, regardless, what you seem to be saying is that it is simply
IMPOSSIBLE for me to provide a multi-line input field in a form from which
I can accurately pick up what a user types in, if it's possible for the
user to start with a blank line. Impossible! This sounds incredibly lame -
surely there has to be a way of doing this. The nature of the fields I'm
prompting for are such that it is quite likely that occasionally a user
will want to put a blank line in at the top. I can't be ignoring it.

By the way, thanks so far for all your input. I do appreciate it, even
though it is going so frustratingly for me...
-dg
Jul 17 '05 #7


dan glenn wrote:

"John Dunlop" <jo*********@jo hndunlop.info> wrote in message
news:MP******** *************** *@News.Individu al.NET...
John Dunlop wrote:
Line breaks immediately following start-tags, any start-tag, *must*
be ignored. That means any line breaks after the TEXTAREA start-tag
ought to be ignored.


No it doesn't John! I don't know what I'm saying.

A *single* line break following a start-tag must be ignored.

--
Jock


I'm just curious - WHY in all of creation MUST a linebreak immediately
following any start-tag be ignored??? This is not clear to me. First of
all, it doesn't make any sense to be talking about "linebreaks immediately
following a start tag". The <textarea ...> </textarea> tags are in the php
source merely to contain the starting value for the field and define
the size of the input box that the browser will create - the rows and
cols callouts define the size of the "box" that the user can type into.
When the user types in an initial linebreak, he is not typing it in
immediately after any start-tag! There are no tags at all at this point
- just the input fields that were created by tags when the page loaded.
That input box is dead empty when he starts - there's no reason the
initial linebreak should be ignored any more than any initial character,
that I can see.

I just tested my little testtextarea.ph p program in all my browsers,
and I find that in Opera the leading linebreak is NOT lost. Yea Opera!
In IE, NN, and Mozilla, it gets gobbled. Opera is behaving correctly,
the others are in error, in my opinion, as little good as that's worth.

Anyway, regardless, what you seem to be saying is that it is simply
IMPOSSIBLE for me to provide a multi-line input field in a form from which
I can accurately pick up what a user types in, if it's possible for the
user to start with a blank line. Impossible! This sounds incredibly lame -
surely there has to be a way of doing this. The nature of the fields I'm
prompting for are such that it is quite likely that occasionally a user
will want to put a blank line in at the top. I can't be ignoring it.

By the way, thanks so far for all your input. I do appreciate it, even
though it is going so frustratingly for me...


Actually,
<textarea>
//print stuff here
</textarea>

should work. Though that'll probably add an extra line on opera, unless you
check the useragent (which is unreliable due to user preferences) and adjust
your HTML accordingly :(

Ignoring a line break after an opening tag allows more-readable HTML code.
You're not forced to put all code on a single line if you want to prevent extra
spaces being added.

Regards,
Shawn
--
Shawn Wilson
sh***@glassgian t.com
http://www.glassgiant.com
Jul 17 '05 #8
"dan glenn" <da********@yah oo.com> wrote in message news:<9HT_b.299 19
<form action="testtex tarea.php" method="POST">
<textarea wrap="soft" cols=40 rows=12
name="t_textare a">$t_textar ea</textarea>


change
name="t_textare a">$t_textar ea</textarea>

to: Note the space.
name="t_textare a"> $t_textarea</textarea>

This fixed it in Konqueror and Mozilla.

Justin
Jul 17 '05 #9
dan glenn wrote:
First of all, it doesn't make any sense to be talking about "linebreaks
immediately following a start tag".
I think it does. This is all about your browser's presentation of
the data, not what is sent to the server. You'd be better off
discussing this in an HTML group (you'd be even better off reading
past discussions from an HTML group). And by that token, it's off-
topic here. But since we've made it this far...

I'm assuming the data is passed correctly to your PHP script. Check
the actual data to confirm this. By changing the method to GET,
you'll see what is passed in the query component. Line breaks will
be represented, in the default encoding, by %0D%0A (a CRLF pair).
You'll see something like:

http://domain.example/path?t_textare...this+is+a+line

The value of t_textarea is, unencoded: two line breaks and the string
"this is a line". Echoing this into a TEXTAREA:

<TEXTAREA rows=5 cols=20>$data</TEXTAREA>

results in the first line break being ignored. That's the theory at
least; whether mainstream browsers get this right is another matter.
If, however, you wrote:

<TEXTAREA rows=5 cols=20>
$data</TEXTAREA>

you've introduced a line break of your own, which ought to be
ignored, so the line breaks of the user's data won't get ignored.
I just tested my little testtextarea.ph p program in all my browsers,
and I find that in Opera the leading linebreak is NOT lost.
Which Opera? My 7.10 seems to ignore line breaks in TEXTAREAs up to
the first non-white space character. From what I can see, both
Internet Explorer 6.0 (somewhat surprisingly!) and Mozilla 1.3 don't.
Anyway, regardless, what you seem to be saying is that it is simply
IMPOSSIBLE for me to provide a multi-line input field in a form from
which I can accurately pick up what a user types in, if it's possible
for the user to start with a blank line.


No. I'm definitely not saying that. The "picking up" part should
work, and there's very little you can do about it if it doesn't: it's
a browser issue.

HTH.

--
Jock
Jul 17 '05 #10

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

Similar topics

2
4264
by: \Dandy\ Randy | last post by:
Hello everyone. I have been following misc posts, as well as reading several FAQ's on this issue, unfortunatley I cannot locate a solution. I am hoping that someone will be able to provide me with the simple answer. My problem has to do with the leading white spaces after the first line when calling data using the @ variable. Here is my code: open (PREVIEW, "<preview.txt") or &error("Unable to open the data file for reading"); flock...
1
2784
by: Scott Lyon | last post by:
I'm maintaining (read: I didn't write it, nor do I have the time to spend to rewrite it) an application that is suddenly giving me grief. The reason I say suddenly, is because we're in the process of transitioning the server on which it runs from Microsoft Windows 2000 Server, to 2003 server (going from IIS 5 to IIS 6). This problem hasn't really occurred on the 2000 server machine, but it's happening MUCH more on the new 2003 box (not...
2
1808
by: James | last post by:
Session("UserName") is set when someone logs in. Get to a page that displays a record where you can type a comment. The form has an onSubmit event that calls a javascript function. That function sets a javascript variable called beenChecked = true and then calls a PopUp window to spell check the comment. When it's done spell checking, it calls the submit method on the form tag of the opening window. The method evaluates that it's...
26
4812
by: steve | last post by:
Well I've been working all morning and have finally found the source of my "bus error (signal 10)" errors. The source is odd. The error occurs in any function where I make the function call: (void)sprintf(ptr_testing, "This is my string"); This in itself isn't where the actual error occurs. The error occurs at any later point, in the same function where the sprintf() call is made, where I try to assign a value to one of the...
6
3464
by: Dean Fields | last post by:
Hello, I am having some session problems wih an in-house (classic) asp application. My developers have not been able to figure it out. I am more of a systems admin type and much of this is over my head. But I will try to explain the best I can and tell you what I know so far. First a little summary of environment. I am running iis6 in a web farm with hardware NLB and 5 servers. Each server is identical. Each server uses a hosts file...
1
1610
by: David | last post by:
Hi, using .NET 1.1 C# I am trying to determine page generation time. I have TimeSpan RenderTime = DateTime.Now - PageTime; (pagetime was set up in oninit, Rendertime is in the render I am using RenderTime.Seconds and RenderTime.Milliseconds in my string. (In the brackets is just RenderTime, so that you can see the correct value)
2
2816
by: GS | last post by:
How can one avoid capturing leading empty or blank lines? the data I deal with look like this "will be paid on the dates you specified. xyz supplier amount: $100.52 when: September 07, 2007 reference #: 0415 from: operating account
9
3020
by: jbaranski | last post by:
Access 2003 on XP pro machine... i'm running a crosstab query and an export to a 3rd party company showing different benefit plans for employees; specifically dental, vision and medical pulling the effective dates (date which the plan when into effect). generally the plans all have the same effective date. however in the case they don't 2 lines are returned for the same employee; the first containing, for example, their medical and vision...
3
4528
by: joelkeepup | last post by:
Hi, im trying to create a text email message using xslt template , the transforms work great, but the newlines and whitespace in the xslt doc are removed. Is there a setting somewhere I have missed: My template is: <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/ Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result- prefixes="msxsl">
0
8788
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9476
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9335
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8210
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6751
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4570
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4825
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3279
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2745
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.