PDA

View Full Version : passing value


cooldaddy
11-03-2005, 12:38 PM
I retrieve a form's textarea value with: $texT=$q->param('text');
I add some text to it, and print it out again to the textarea with:
print qq{<textarea>$texT</textarea>};

However, all carriage returns the visitor entered are gone. How come, and what to do about it ?

Please note I cant display html within a textarea

nkrgupta
11-03-2005, 12:43 PM
I add some text to it, and print it out again to the textarea with:
print qq{<textarea>$texT</textarea>};


How do you add text to it? It would be helpful if you post the relevant piece of code.

Naveen

cooldaddy
11-03-2005, 12:55 PM
well actually i didnt add text to it yet. But it's allready buggy without adding anything to it.

#!/usr/bin/perl
use CGI;
use Fcntl qw(:flock);
use headups;
use lib "/home/users/web/b2495/hy.mysite/";
require Valid;
$q=new CGI;
print "Content-type: text/html\n\n";

if ($q->param('submit') eq "Prv"){
$texT=$q->param('text'); $texT =~ s/^\s+|\s+$//g; &showform;

sub showform{
print qq{<textarea>$texT</textarea>};
}

mlseim
11-03-2005, 03:52 PM
You might try this ... (I didn't actually try it myself).

Change the "newlines" to an unusual character, like pipes '|'
Add your text.
Then change the pipes back to "newlines" (\n) before displaying it.


$texT=$q->param('text');

$texT =~ s/\n/\|/g; #change newlines (carriage returns) to pipes.

#add your text.

$texT =~ s/\|/\n/g; #change the pipes back to newlines.

#for HTML stuff, newlines would be <br>'s ...
# $texT =~ s/\n/<br>/g;