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

Hi Monks,
Here is a simple example what I do. Inside the loop using scrolling_list()I create a scrol box with text. But I want each new box to replace an old one. I am ok if it requires to start a new page. No AJAX suggestions, please. What I actually need is to renew the box content based on the new array content which I will have from some request (this is not implemented yet). But these are all details. The main question is how to renew the page.
Thanks, Vitaly
use CGI; use strict; my $query = new CGI; for (my $ii = 1; $ii<=2; $ii++) { print $query->header; print $query->start_html('My scrolling_list.cgi program'); my @lang = ( 'Basic ', 'C', 'C++', 'Cobol', 'DHTML', 'Fortran', 'HTML', 'Korn Shell (Unix)', 'Perl Perl Perl Perl Perl P +erl Perl Perl Perl Perl Perl Perl ', 'Java', 'JavaScript', 'Python', 'Tcl/Tk', 'Visual Basic'); print $query->startform; print $query->h3('Select your favorite programming language(s):'); print $query->scrolling_list(-name=>'languages', -values=>\@lang, -size=>8, -multiple=>'true' ); print $query->br; #print $query->submit(-value=>'Submit your favorite language(s)'); print $query->endform; print $query->end_html; }

Replies are listed 'Best First'.
Re: Update page inside CGI/Perl sript
by Gangabass (Vicar) on Dec 13, 2007 at 03:11 UTC

    To reload page on client side you need some code on client side. Maybe in HTML

    <meta http-equiv="refresh" content="5" />

    Also you can change content of any element in HTML page using Javascript. Just send all data via Javascript array for example and after that read each element of array in Javascript and change content of your text box.

    But Perl can't do anything on client side (of course if this is not PerlScript).

      The array contents can be stored in a flat file line by line or using a delimeter. Then perl code can be written to read the file and store the elements in the @lang array. So when a new item needs to be added just add it to the flat file.