Jarek has asked for the wisdom of the Perl Monks concerning the following question:

Hi everyone, What I think is. If is there any way to display a page in CGI, where you've got some news for example and you would have something in the code like:
#!/usr/bin/perl -w use warnings; use CGI; my $content = new CGI; print $content->header("text/html"); print "SOME TEXT HERE"; <SUBMIT BUTTON WITH ACTION SOME ACTION (WHAT ACTION?)- MUST BE PRESSED + IF YOU WANT TO READ MORE> if ( $pressed ) { print "REST OF THE PAGE"; } print $content->end_html;
I hope you know what I mean. Generaly I want to execute the rest of the code when button was pressed. Is there any simple way to do it ? Regards, Jarek

Replies are listed 'Best First'.
Re: How to display part of the page when click on submit (CGI)
by zwon (Abbot) on Nov 13, 2009 at 19:49 UTC
    use strict; use warnings; use CGI; if($ENV{REQUEST_METHOD} eq 'GET') { # print form with method 'POST' and submit button } else { # print the rest of the page }

    Perhaps AJAX would suit you better for this.

    I hope you know what I mean.

    Sure, I'm certified telepathic :)

      Hehe, thanks. The problem is I cant reload the page, as it's executed by remote site using CURL. I have looked around and I haven't found anything better than AJAX. The problem is I'm not familiar with AJAX at all. Thank you again. Regards.