textarea problem

P

Paul Lalli

I have a textarea in a script that displays and when the user submits
something it sends the output to the browser from the textarea, why is is
that when I press the return key within the textarea and type more text
below my carriage return does that text below the carriage not display? I
don't have any special parse code, I'm using cgi.pm.

After everything, you STILL refuse to follow the posting guidelines? What
part of "post a short but complete program that demonstrates your problem"
is difficult for you to understand?

It amazes me you still expect people to help you.
 
R

Richard Morse

Robin said:
I have a textarea in a script that displays and when the user submits
something it sends the output to the browser from the textarea, why is is
that when I press the return key within the textarea and type more text
below my carriage return does that text below the carriage not display? I
don't have any special parse code, I'm using cgi.pm.

When you're entering the text? Or when you are later displaying the
text?

If the former, look to the HTML specification -- you may need to specify
more rows to your textarea. If the latter, you would need to make sure
that your processing of the data properly handles cases where there are
embedded newlines.

Ricky
 
P

Paul Lalli

ok, I'll demonstrate, I thought this would be an easy one.


use strict;
use CGI qw :)standard);

mainprint ();
output();

sub mainprint
{
print header;
print <<END;
<html><body><form action="thisscript.pl" method="post"><textarea
name="test"></textarea></form></body></html>
END
print "\n";
}

sub output
{
if (param ('test'))
{
print (param ('test'));
}
}

#untested

Clearly, it's untested. If you had tested it, first you would have found
there's no submit button. Once you added that in, you'd have found that
IT WORKS FINE. All the text is displayed no problem. So one more time,
POST A COMPLETE SHORT PROGRAM DEMONSTRATING YOUR PROBLEM. Why do you have
so much reluctance to do that? Seriously. I really do not understand.
The script prints everything on the first line of the textarea before my new
line with the return key.... anyone know why?

Really? Where? Show me. Give me the URL and the ability to view the
source code.
 
R

Robin

I have a textarea in a script that displays and when the user submits
something it sends the output to the browser from the textarea, why is is
that when I press the return key within the textarea and type more text
below my carriage return does that text below the carriage not display? I
don't have any special parse code, I'm using cgi.pm.

Thanks in advance.
 
R

Robin

this is totally off-topic, but for anyone who wants to post and read on a
free server, I found a good one, it's
news.f.de.plusline.net
-Robin
 
R

Robin

After everything, you STILL refuse to follow the posting guidelines? What
part of "post a short but complete program that demonstrates your problem"
is difficult for you to understand?

It amazes me you still expect people to help you.

ok, I'll demonstrate, I thought this would be an easy one.


use strict;
use CGI qw :)standard);

mainprint ();
output();

sub mainprint
{
print header;
print <<END;
<html><body><form action="thisscript.pl" method="post"><textarea
name="test"></textarea></form></body></html>
END
print "\n";
}

sub output
{
if (param ('test'))
{
print (param ('test'));
}
}

#untested


The script prints everything on the first line of the textarea before my new
line with the return key.... anyone know why?
-Robin
 
R

Robin

that your processing of the data properly handles cases where there are
embedded newlines.

right, and how would I do this, I've been racking my brains for a while on
this one... is it % followed by something like %20 is a space that I have to
replace with a newline.
-Robin
 
R

Robin

Robin said:
I have a textarea in a script that displays and when the user submits
something it sends the output to the browser from the textarea, why is is
that when I press the return key within the textarea and type more text
below my carriage return does that text below the carriage not display? I
don't have any special parse code, I'm using cgi.pm.


I'm posting this so users won't get confused with textareas and cgi.

it was a problem with the script, not a problem with the textarea or the
parse code. I was basically reading the lines from a textarea into a text
file, and before the textarea I'd put a number and then a special string (to
split) and then an indentifier, post or comment, and then the textarea
contents. The problem was whenver the textarea input included a newline it
would screw up the way the file was parsed and printed later on, I finally
figured out that all I had to do was remove the newlines and replace them
with "<br>" and then remove the carriage returns and replace them with
nothing so it would be a "<br>" everytime someone inputed a newline into the
text area. The code is as follows.
$posttext = param ('posttext');
$posttext =~ s/\r/<br>/m;
$posttext =~ s/\n//m;
#and then I printed param ('posttext') - and it worked

I'm stupid.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top