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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

\n textarea insert newlines into textarea

Status
Not open for further replies.

jamsman

Technical User
Jul 22, 2005
38
DE
im trying to write output into a textarea and i want to insert some newline with it but all iget is \n printed in the textarea along with the rest of my output

any ideas

thanks for the help :)
 
<br>

these are the newlines of the web


Kind Regards
Duncan
 
if i put that into my coed all i get is the my text sperarted by <br> in the textarea do i have to escape it or quote it??
 
this is the part that i join an array together

my $att_name = join '<br>',@att_name;

i guess this is the important part

does it help or do you want more?
 
Single quotes will cause a that string to be interpreted literally. That means that when you use '\n', you literally mean a backslash character followed by the letter 'n'. If you wanted \n to be a newline character, you'd need to change the single quotes to double ones. I suspect that's your problem.
 
sorry - i misunderstood your question

this takes it a bit further - and sorts out your problem

Code:
[b]#!/usr/bin/perl[/b]

print "Content-type: text/html\n\n";

read (STDIN, $buffer, $ENV{'CONTENT_LENGTH'});

if ($buffer) {

  print "We have POST data...<br>";
  print $buffer;
  
  $buffer =~ s/^editfield=//;
  
  $buffer =~ s/%0D%0A/\n/g;
  
  open (OUT, "> user_editable.txt");
  print OUT $buffer;
  close OUT;
  
}

open (IN, "< user_editable.txt");
undef $/;
$_ = <IN>;
$/ = "\n";
close IN;

print <<HTML;
<form action=$0 method=POST>
  <textarea cols=50 rows=10 name=editfield>$_</textarea>
  <input type=submit>
</form>
HTML
# end of script

check out the link again


Kind Regards
Duncan
 
again thanks for the help sorted it out :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top