Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Processing Textarea data

by atcroft (Abbot)
on May 17, 2004 at 15:10 UTC ( [id://353992]=note: print w/replies, xml ) Need Help??


in reply to Processing Textarea data

My first guess is that your email is plain text-correct? In HTML, carriage returns in the source are not displayed (unless within <pre></pre> tags). So, I see two possibilities (at least):

  • in the section where you display the results, place a set of <pre> tags around $name, or
  • after sending the email, but before displaying the results, do a search and replace on \n with <br />\n.

For my part, I would try the first one (as it would be the easier of the two).

Hope that helps.

Replies are listed 'Best First'.
Re: Re: Processing Textarea data
by ambrus (Abbot) on May 17, 2004 at 15:18 UTC

    Tricky question, eh? I think this is a wrong answer, see, the poster already adds <BR /> so that the newlines show up in the html. I almost got fooled with this one too.

    Update: Sorry, atcroft, this post was a bit too harsh (or cheeky). I'm now not so sure if param really returns an array or a scalar here. I'd still guess scalar, because anonymonk says in the question

    The emails come back with names seperated by CR
    Note also that in ruby, for on a string iterates through its lines (as defined by $/, the record separator); which may be the source of confusion.

    Anyway, adding a <PRE> is a good solution in either case.

      Actually, given that the email displays them as the OP desires, but that he wants the results to show up on the web page in the same manner, <pre></pre> tags around the variable will in fact take care of the issue, without having to worry about looking at the parameter in question as a scalar or array.

      Test results, result display section, CGI based on OP's provided code
      TestHTML codeDisplayed
      Sample results, original code
      <html> <body> Names here: duh<br />Names here: joe bob mary<br /> </body> </html>
      Names here: duh
      Names here: joe bob mary
      Sample results, <pre></pre> tags around $name
      <html> <body> <pre> Names here: duh<br />Names here: joe bob mary<br /> </pre> </body> </html>
      Names here:	duh
      Names here: joe bob mary

      HTML code, for reference:

      <html> <head> </head> <body> <form action="/cgi-bin/testdump.pl" method=post> <table> <tr><td>Department</td> <td><input type=text name=department></td> </tr> <tr> <td colspan=2>People</td> </tr> <tr> <td colspan=2> <textarea name=people rows=5 cols=40></textarea> </td> </tr> <tr> <td><input type=submit></td> <td><input type=reset></td> </tr> </table> </form> </body> </html>

      perl code, for reference:

      #!/usr/bin/perl use CGI qw/:standard/; $| = 1; foreach my $field (param) { foreach my $value (param($field)) { $name .= "Names here\:\t$value<br />"; } } # Mailer section removed from OP's code for testing print header, <<EOF; <HTML> <BODY> <pre> $name </pre> </BODY> </HTML> EOF

      Hope that helps.

      Actualy he only puts the br after the value. It looks like its printing "Names:" followed by all the names grouped together. Viewing the source would probably show all the names on seperate lines. I think atcroft is quite right here but then we need the OP to be a little more specific about what he _is_ getting.


      ___________
      Eric Hodges

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://353992]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2024-04-25 05:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found