Print a perl array to html textarea ...

M

Moti

Hi Guys,
After I got my indigoperl to work I want to build an application that
get data from the html textarea parse it and then return it to the
same text area (deleting the original text).
My parser returns a perl array (@output_array) which I want to print
to the html text area.
Where can I find an example on how to perfrom this ?
Thanks in advance, Moti.
 
P

Paul Lalli

Hi Guys,
After I got my indigoperl to work I want to build an application that
get data from the html textarea parse it and then return it to the
same text area (deleting the original text).
My parser returns a perl array (@output_array) which I want to print
to the html text area.
Where can I find an example on how to perfrom this ?

perldoc CGI

as an example...
use CGI qw/:standard/;
print textarea(
-name=>'mytext',
-rows=>10,
-columns=>50,
-default=>join('', @output_array)
);


Paul Lalli
 
M

Moti

perldoc CGI

as an example...
use CGI qw/:standard/;
print textarea(
   -name=>'mytext',
   -rows=>10,
   -columns=>50,
   -default=>join('', @output_array)
);

Paul Lalli


Thanks for your answer Paul, but can I use the above example in order
to write to the same textarea I read from ?
Just to calrify - I dont want to create a new html document - I just
want to read the data from my existing html textarea, process it and
then write it back to the same form.

Another question if I may, It seems that there is a limition on the
size that I can read from my textarea ( I'm reading using the
$text_area_code = $cgi->param('text_area_data'); )
It seems that if the textarea contains more than 60 lines an error is
generated by the server.

Lots of questions :) I hope its OK.

Thanks, Moti.
 
J

Jürgen Exner

Moti said:
Thanks for your answer Paul, but can I use the above example in order
to write to the same textarea I read from ?

Without some trickery like client-side scripting or frames or refresh or
similar no. Once a page is rendered it is rendered. There is nothing the web
server can do to override the page content after it has been sent to the
client. This is a very fundamental design principle of http and has
absolutely nothing to do with Perl.
Just to calrify - I dont want to create a new html document - I just
want to read the data from my existing html textarea, process it and
then write it back to the same form.

This is impossible by design of HTTP. Yes, there are ways to work around the
static nature of web pages but that is about web page programming and has
nothing to do with Perl.
Another question if I may, It seems that there is a limition on the
size that I can read from my textarea
It seems that if the textarea contains more than 60 lines an error is
generated by the server.

"An error" is about the worst possible description of a problem. _WHAT_
error message are you getting?
Always copy-and-paste, don't retype or paraphrase them. Or even worse don't
keep the text a secret.

jue
 
U

Uri Guttman

SB> Or AJAX.

what do you think ajax IS? it is client side scripting but just more
bundled up.

uri
 
L

lihao0129

  SB> Jürgen Exner wrote:
  >> Without some trickery like client-side scripting or frames or refresh or
  >> similar no.

  SB> Or AJAX.

what do you think ajax IS? it is client side scripting but just more
bundled up.

AJAX can surely handle this nicely without refreshing the whole page,
this is almost a basic AJAX applicaiton pattern. you can conduct a
'POST' instead of 'GET' HTTP method and send the texearea content back
to the server and then retrive the result from the client side. If you
get multiple fields to change on the client side, just use JSON from
both sides. I am using this approach to handle 'Preview' functionality
of my blog entry which is a textarea element and it worked pretty
well.

BTW. I am using HTML::Mason and JSON, no CGI::AJAX involved.

lihao(XC)
 
L

lihao0129

AJAX can surely handle this nicely without refreshing the whole page,
this is almost a basic AJAX applicaiton pattern. you can conduct a

that means with AJAX you can refresh only the content in the
"textarea" element while all other HTML elements on the same page keep
untouched. all backend client-server interactions influence on only
this textarea element. (you can specify more fields to update for
sure..)

lihao(XC)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top