Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trouble populating textarea

Status
Not open for further replies.

dpm8

Programmer
Dec 14, 2004
8
0
0
US
Hey there.

I'm trying to pull the text from a file in my current directory called news.txt. With that text, i want' to populate a textarea so it is editable. But i can't seem to get all the lines from the file in there.

Any tips?

Heres the code.

#!/usr/local/bin/perl -w
use CGI qw:)standard);
use CGI::Carp qw(fatalsToBrowser warningsToBrowser carpout);
warningsToBrowser(1); # activate warnings

open NEWS, "<news.txt"
or die "Coulden't open news.txt: $!.";

my $counter = 0;

while (<NEWS>)
{
$lines[$counter] = "$_\n";
$counter++;
}

close NEWS;
print header, "\n";
print "Here is counter $counter\n";
print "here is lines @lines[0]\n";

print start_form, "\n",
br, br, "\n",

"Oracle username: \n",
textarea(-name=>'news_text',
-default=>@lines,
-rows=>40,
-columns=>60), "\n",

br, br, "\n",

submit(-value=>'post news'), "\n",
endform, "\n";

print hr, "\n";

if (param())
{

my @text = param('news_text')
or die "Must have news text\n";

open NEWS, ">news.txt"
or die "Coulden't open news.txt: $!.";

foreach $line (@text)
{
print NEWS "$line\n";
}
}
 
instead of
Code:
"Oracle username: \n",
textarea(-name=>'news_text',
-default=>@lines,
-rows=>40,
-columns=>60), "\n",
try this and let us know how you get on
Code:
"Oracle username: \n"[b];
print "<textarea name='news_text' rows=40 columns=60>@lines</textarea>";
print[/b] "\n",

--Paul
 
That worked great, Paul. Thanks. However, I'm not able to make the text area wider. I've turned the columns up to 100 and it still stays very slim, enough for about 4 words before it wraps around. Any Ideas?

Thanks.
Danny
 
cols=60

... I think

--Paul

sorry for misleading you on that one


cigless ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top