Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

CGI::ProgressBar Module Help Required

by slb985 (Initiate)
on Feb 26, 2013 at 14:13 UTC ( [id://1020697]=perlquestion: print w/replies, xml ) Need Help??

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

I am trying to use the perl module CGI::ProgressBar

When I use the example code from the cpan page I dont see a progress bar on my browser. The page just seems to hang for the duration of the test then displays the final page.

I am pretty sure I have the prereqs in terms of javascript enabled on browser etc. Any help would be greatly appreciated

Code I am using is

use strict; use warnings; use CGI::ProgressBar qw/:standard/; $| = 1; # Do not buffer output print header, start_html( -title=>'A Simple Example', -style=>{ -src => '', # You can override the bar style +here -code => '', # or inline, here. } ), h1('A Simple Example'), p('This example will update a JS/CSS progress bar.'), progress_bar( -from=>1, -to=>100 ); # We're set to go. for (1..10){ print update_progress_bar; # Simulate being busy: sleep 1; } # Now we're done, get rid of the bar: print hide_progress_bar; print p('All done.'); print end_html; exit;

Replies are listed 'Best First'.
Re: CGI::ProgressBar Module Help Required
by Anonymous Monk on Feb 27, 2013 at 08:32 UTC
    Hi slb985,

    Here is my part of research on your question.

    I too tried the same code and getting same result, could not see the progress bar

    I am using firefox 19.0, I checked the Error Console, I found that , it says ReferenceError:pblib_progress_update not defined

    But It seems that the pblib_progress_update() is defined in between <script> tag

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-U +S"> <head> <title>A Simple Example</title> <style type="text/css"> <!--/* <![CDATA[ */ print 'test' /* ]]> */--> </style> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1 +" /> </head> <body> <h1>A Simple Example</h1><p>This example will update a JS/CSS progress + bar.</p><style type='text/css'> .pblib_bar { border: 1px solid black; padding: 1px; background: white; display: block; text-align:left; width: 400px; } .pblib_block_on, .pblib_block_off { display: block; float:left; width: 38px; } .pblib_block_off { border:1px solid white; background: white; } .pblib_block_on { border:1px solid blue; background: navy; } </style> <div id='pb_cont1361953714'> <div class='pblib_bar'> <span class='pblib_block_off' id='b13619537141'>&nbsp;</span><span + class='pblib_block_off' id='b13619537142'>&nbsp;</span><span class=' +pblib_block_off' id='b13619537143'>&nbsp;</span><span class='pblib_bl +ock_off' id='b13619537144'>&nbsp;</span><span class='pblib_block_off' + id='b13619537145'>&nbsp;</span><span class='pblib_block_off' id='b13 +619537146'>&nbsp;</span><span class='pblib_block_off' id='b1361953714 +7'>&nbsp;</span><span class='pblib_block_off' id='b13619537148'>&nbsp +;</span><span class='pblib_block_off' id='b13619537149'>&nbsp;</span> +<span class='pblib_block_off' id='b136195371410'>&nbsp;</span> </div> </div> <script language='javascript' type='text/javascript'> // <!-- var pblib_at = 1; pblib_progress_clear(); function pblib_progress_clear() { for (var i = 1; i <= 10; i++) document.getElementById('b1361953714'+i).className='pblib_ +block_off'; pblib_at = 1; } function pblib_progress_update() { pblib_at += 1; if (pblib_at > 10){ pblib_progress_clear(); } else { for (var i = 1; i <= Math.ceil(pblib_at); i++){ document.getElementById('b1361953714'+i).className='pb +lib_block_on'; } } //--> </script> <script type='text/javascript'> pblib_progress_update() </script> <script type='text/javascript'> pblib_progress_update() </script> <script type='text/javascript'> pblib_progress_update() </script> <p>All done.</p> </body> </html>

      Oops Its me

      It looks like function pblib_progress_update() is missing a closing }. The for {} is ok, the else {} is ok, but the function isn't.

        Thank you vinoth.ree & redgreen. I will take a look at what you've found and let you know how I get on

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1020697]
Approved by marto
Front-paged by ww
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (3)
As of 2024-03-19 05:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found