using data from HTML textarea 
Author Message
 using data from HTML textarea

Hi,

I trying to pass the input from an HTML textarea form to a perlscript.
In my HTML page I have the following code:

...

<form method=GET action="cgi-bin/pwc.cgi">

...

<table border=0>
   <tr valign=top>
      <td align=left><textarea name="envelope" cols=18 rows=6></textarea>
      </td>
   </tr>

...

The user can type in several numbers, one on a line, eg:

865.444
894.763
1098.666

etc

In my perlscript (pwc.cgi), I try to access the list with numbers, and
use it to do some calculations.

First I would like to print the numbers:

If I use


I see all numbers in one row.

However for:


   print( $i );

nothing is displayed on the screen.

If I look at the data that is passed in the URL, I see something like
this: ../cgi-bin/pwc.cgi?envelope=865.444%0D%0A894.763%0D%
0A1098.666%0D%0A

So not only the three numbers are passed in envelope. What are these
extra characters, and how do I get rid of them, leaving a list with just
the numbers?

thanks,

- Koen.

--
- Koen.



Fri, 03 Sep 2004 06:30:23 GMT  
 using data from HTML textarea
Those are encode ascii representations of the CRLF characters that were in
your
textarea.  If you had typed 1 2 3 4, you would have gotten 1%202%203%204%20
ther %20 represents the ascii value for a space 0x20.

I see the following line in scripts all the time:

$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;

to convert them to something.

Bruce


Quote:
> Hi,

> I trying to pass the input from an HTML textarea form to a perlscript.
> In my HTML page I have the following code:

> ...

> <form method=GET action="cgi-bin/pwc.cgi">

> ...

> <table border=0>
>    <tr valign=top>
>       <td align=left><textarea name="envelope" cols=18 rows=6></textarea>
>       </td>
>    </tr>

> ...

> The user can type in several numbers, one on a line, eg:

> 865.444
> 894.763
> 1098.666

> etc

> In my perlscript (pwc.cgi), I try to access the list with numbers, and
> use it to do some calculations.

> First I would like to print the numbers:


> If I use


> I see all numbers in one row.

> However for:


>    print( $i );

> nothing is displayed on the screen.

> If I look at the data that is passed in the URL, I see something like
> this: ../cgi-bin/pwc.cgi?envelope=865.444%0D%0A894.763%0D%
> 0A1098.666%0D%0A

> So not only the three numbers are passed in envelope. What are these
> extra characters, and how do I get rid of them, leaving a list with just
> the numbers?

> thanks,

> - Koen.

> --
> - Koen.



Sat, 04 Sep 2004 16:20:30 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. using data from HTML textarea

2. submit a HTML file using a textarea within a form

3. Insert textarea data into mysql text field

4. Insert textarea data into mysql text field

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

6. using perl CGI to automatically post data to an HTML form

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

8. HTML::FORM textarea

9. Converting Textarea text into HTML code with tags ???

10. HTML-code in textarea

11. TEXTAREA field using CGI.pm

12. Need Help in preparing Textarea for POST method using LWP::UserAgent

 

 
Powered by phpBB® Forum Software