CGI.pm textarea 
Author Message
 CGI.pm textarea

Hello,

I'm using perl5.004_04.  CGI.pm doesn't recognize the "wrap' attribute.
Is this because it's an 'Extension'?

I want to set wrap = physical, like:

  print $query->textarea(-name=>'comments',-default=>'',
                -rows=>10,-columns=>60,-wrap=>'physical');

The lines wrap on screen within the textarea, but what gets sent to the
server is one long line.

I have a little loop that inserts newline after every 70 characters.
Am I assuming correctly, or missing something here?

Thanks,
--irene

-------------------------------------------------------------------

Steward Observatory             Phone:  520-621-2602
University of Arizona           FAX:    520-621-1891
Tucson, AZ  85721               http://www.*-*-*.com/ ~barg
-------------------------------------------------------------------



Fri, 29 Sep 2000 03:00:00 GMT  
 CGI.pm textarea


Quote:
> CGI.pm doesn't recognize the "wrap' attribute.

Could you check to see whether it's sending the wrong data to the browser?
If so, that may be a bug which you should report to the module's author.
Of course, you should double-check that you're using the module properly,
first. Hope this helps!

--
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



Sat, 30 Sep 2000 03:00:00 GMT  
 CGI.pm textarea

Quote:

>Hello,

>I'm using perl5.004_04.  CGI.pm doesn't recognize the "wrap' attribute.
>Is this because it's an 'Extension'?

>I want to set wrap = physical, like:

>  print $query->textarea(-name=>'comments',-default=>'',
>  -rows=>10,-columns=>60,-wrap=>'physical');

>The lines wrap on screen within the textarea, but what gets sent to the
>server is one long line.

>I have a little loop that inserts newline after every 70 characters.
>Am I assuming correctly, or missing something here?

>Thanks,
>--irene

What is the problem exactly? CGI.pm produces the HTML code from which
the browser generates a form. When you call
print $query->textarea(-name=>'comments',-default=>'',
 -rows=>10,-columns=>60,-wrap=>'physical');

Then CGI.pm only creates something like:
<TEXTAREA NAME="comments" ROWS=10 COLUMS=60 WRAP="physical">
</TEXTAREA>
This then tells the browser to physicly wrap the lines. If these lines
then subsequently are sent to the server without having been wrapped,
than this is the browsers fault, not CGI.pm's. If however, the HTML
sent to the browser is incorrect (like the WRAP attribute missing),
then CGI.pm is in the wrong.

When the data is sent from the browser to your CGI.pm script, you
cannot assume that this data will be wrapped, though. WRAP is not a
standard attribute (not even in HTML 4.0), and so not all browsers
support it. Applying wrapping after receiving it from the browser
is therefore always a good idea. Perl even has a module for it:
Text::Wrap. Just type perldoc Text::Wrap at your command line for
more information.
As a quick start:
use Text::Wrap;
Text::Wrap::colums = 70;
$wrapped = wrap('', '', $text_to_be_wrapped);

This should wrap your text neatly, at whitespace, with a maximum line
length of 70 characters.

Hope this helps.

Martijn Pieters

--
M.J. Pieters, Web Developer
| Audax Tros MultiMedia http://www.atmm.nl
| Tel: +31-35-6254545 Fax: +31-35-6254555

------------------------------------------



Sun, 01 Oct 2000 03:00:00 GMT  
 CGI.pm textarea

First, thanks to everyone who responded to this query.  I looked at the
CGI.pm module and it doesn't support the 'wrap' option.  However, based
on everyone's response, it's really a browser issue.  Martijn Pieters
suggestion to use Perl Text::Wrap will work fine and is much simpler than
the one I wrote.

Thanks again,
--irene

|> >Hello,
|> >
|> >I'm using perl5.004_04.  CGI.pm doesn't recognize the "wrap' attribute.
|> >Is this because it's an 'Extension'?
|> >
|> >I want to set wrap = physical, like:
|> >
|> >  print $query->textarea(-name=>'comments',-default=>'',
|> >  -rows=>10,-columns=>60,-wrap=>'physical');
|> >
|> >The lines wrap on screen within the textarea, but what gets sent to the
|> >server is one long line.
|> >
|> >I have a little loop that inserts newline after every 70 characters.
|> >Am I assuming correctly, or missing something here?
|> >
|> >Thanks,
|> >--irene
|> >
|>
|>
|> What is the problem exactly? CGI.pm produces the HTML code from which
|> the browser generates a form. When you call
|> print $query->textarea(-name=>'comments',-default=>'',
|>  -rows=>10,-columns=>60,-wrap=>'physical');
|>
|> Then CGI.pm only creates something like:
|> <TEXTAREA NAME="comments" ROWS=10 COLUMS=60 WRAP="physical">
|> </TEXTAREA>
|> This then tells the browser to physicly wrap the lines. If these lines
|> then subsequently are sent to the server without having been wrapped,
|> than this is the browsers fault, not CGI.pm's. If however, the HTML
|> sent to the browser is incorrect (like the WRAP attribute missing),
|> then CGI.pm is in the wrong.
|>
|> When the data is sent from the browser to your CGI.pm script, you
|> cannot assume that this data will be wrapped, though. WRAP is not a
|> standard attribute (not even in HTML 4.0), and so not all browsers
|> support it. Applying wrapping after receiving it from the browser
|> is therefore always a good idea. Perl even has a module for it:
|> Text::Wrap. Just type perldoc Text::Wrap at your command line for
|> more information.
|> As a quick start:
|> use Text::Wrap;
|> Text::Wrap::colums = 70;
|> $wrapped = wrap('', '', $text_to_be_wrapped);
|>
|> This should wrap your text neatly, at whitespace, with a maximum line
|> length of 70 characters.
|>
|> Hope this helps.
|>
|> Martijn Pieters
|>
|> --
|> M.J. Pieters, Web Developer
|> | Audax Tros MultiMedia http://www.atmm.nl
|> | Tel: +31-35-6254545 Fax: +31-35-6254555

|> ------------------------------------------
|>
|>
|>



Fri, 06 Oct 2000 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. CGI.pm: textarea insanity

2. CGI.pm: textarea insanity

3. Converting international characters in textarea (html, cgi.pm, perl)

4. CGI.pm and Javascript - Textarea values

5. textarea in CGI.pm

6. CGI.pm maxlength of textarea

7. TEXTAREA field using CGI.pm

8. CGI.PM and Textareas

9. textarea in CGI.pm

10. problem with CGI.pm and textarea in multipart/form-data forms

11. textarea, javascript and CGI

12. cgi textarea filtering

 

 
Powered by phpBB® Forum Software