Print a perl array to html textarea ...

Print a perl array to html textarea ...

am 04.01.2008 15:16:14 von 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.

Re: Print a perl array to html textarea ...

am 04.01.2008 15:47:38 von Paul Lalli

On Jan 4, 9:16=A0am, Moti wrote:
> 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=3D>'mytext',
-rows=3D>10,
-columns=3D>50,
-default=3D>join('', @output_array)
);


Paul Lalli

Re: Print a perl array to html textarea ...

am 06.01.2008 22:49:38 von Moti

On Jan 4, 4:47=A0pm, Paul Lalli wrote:
> On Jan 4, 9:16=A0am, Moti wrote:
>
> > 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(
> =A0 =A0-name=3D>'mytext',
> =A0 =A0-rows=3D>10,
> =A0 =A0-columns=3D>50,
> =A0 =A0-default=3D>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 =3D $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.

Re: Print a perl array to html textarea ...

am 07.01.2008 01:57:12 von jurgenex

Moti wrote:

>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

Re: Print a perl array to html textarea ...

am 07.01.2008 05:05:08 von Scott Bryce

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

Or AJAX.

http://search.cpan.org/~bct/CGI-Ajax-0.701/lib/CGI/Ajax.pm

Re: Print a perl array to html textarea ...

am 07.01.2008 05:40:54 von Uri Guttman

>>>>> "SB" == Scott Bryce writes:

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.

uri

--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org

Re: Print a perl array to html textarea ...

am 07.01.2008 08:12:18 von lihao0129

On Jan 6, 11:40=A0pm, Uri Guttman wrote:
> >>>>> "SB" == Scott Bryce writes:
>
> =A0 SB> Jürgen Exner wrote:
> =A0 >> Without some trickery like client-side scripting or frames or refre=
sh or
> =A0 >> similar no.
>
> =A0 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)

Re: Print a perl array to html textarea ...

am 07.01.2008 08:27:42 von lihao0129

On Jan 7, 2:12=A0am, "lihao0...@gmail.com" wrote:
> On Jan 6, 11:40=A0pm, Uri Guttman wrote:
>
> > >>>>> "SB" == Scott Bryce writes:
>
> > =A0 SB> Jürgen Exner wrote:
> > =A0 >> Without some trickery like client-side scripting or frames or ref=
resh or
> > =A0 >> similar no.
>
> > =A0 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

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)

> '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.