Print a perl array to html textarea ...

Discussion in 'Perl Misc' started by Moti, Jan 4, 2008.

  1. Moti

    Moti Guest

    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.
    Moti, Jan 4, 2008
    #1
    1. Advertising

  2. Moti

    Paul Lalli Guest

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


    Paul Lalli
    Paul Lalli, Jan 4, 2008
    #2
    1. Advertising

  3. Moti

    Moti Guest

    On Jan 4, 4:47 pm, Paul Lalli <> wrote:
    > On Jan 4, 9:16 am, 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=>'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.
    Moti, Jan 6, 2008
    #3
  4. 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
    Jürgen Exner, Jan 7, 2008
    #4
  5. Moti

    Uri Guttman Guest

    >>>>> "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 ------ -------- http://www.stemsystems.com
    --Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
    Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
    Uri Guttman, Jan 7, 2008
    #5
  6. Moti

    Guest

    On Jan 6, 11:40 pm, Uri Guttman <> wrote:
    > >>>>> "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.


    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)
    , Jan 7, 2008
    #6
  7. Moti

    Guest

    On Jan 7, 2:12 am, "" <> wrote:
    > On Jan 6, 11:40 pm, Uri Guttman <> wrote:
    >
    > > >>>>> "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.

    >
    > 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.
    , Jan 7, 2008
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. keto
    Replies:
    0
    Views:
    907
  2. David Cournapeau

    print a vs print '%s' % a vs print '%f' a

    David Cournapeau, Dec 30, 2008, in forum: Python
    Replies:
    0
    Views:
    337
    David Cournapeau
    Dec 30, 2008
  3. Augustus
    Replies:
    1
    Views:
    340
    Ken Schaefer
    Sep 10, 2003
  4. Textarea Inside of a textarea

    , Feb 4, 2006, in forum: ASP General
    Replies:
    6
    Views:
    318
    Anthony Jones
    Feb 5, 2006
  5. Replies:
    1
    Views:
    297
    Bart Van der Donck
    Jul 4, 2007
Loading...

Share This Page