HTML_Progress
[ class tree: HTML_Progress ] [ index: HTML_Progress ] [ all elements ]
Prev Next
Your first Progress Meter
first steps in the HTML_Progress World

We will start by creating a very simple progress meter. Copy the following code to a file, give it a .php extension, and display it in your browser.

code listing 2.1: a very simple progress meter

  1. <?php
  2. require_once 'HTML/Progress.php';
  3.  
  4. $bar = new HTML_Progress();
  5. $bar->setAnimSpeed(50);
  6. ?>
  7. <html>
  8. <head>
  9. <title>Code listing 2.1 </title>
  10. <style type="text/css">
  11. <!--
  12. <?php echo $bar->getStyle(); ?>
  13. // -->
  14. </style>
  15. <script type="text/javascript">
  16. <!--
  17. <?php echo $bar->getScript(); ?>
  18. //-->
  19. </script>
  20. </head>
  21. <body>
  22.  
  23. <?php
  24. echo $bar->toHtml();
  25. $bar->run();
  26. ?>
  27.  
  28. </body>
  29. </html>

Loading this file in your browser will simply show something like that after few seconds :

Not particulary exciting, but this does show that HTML_Progress is installed correctly and working. If it's not, have a look at the FAQ page to know if your problem is identified.

Let's consider the lines individually:

Line 2 loads the class definitions. Next (line 4) we instanciate an HTML_Progress object.

Line 5, we slow a bit the animation, to see something. By default animation speed is set to zero, and we can think in such case that the progress meter did not run, or just jump from 0 to 100 without doing nothing else. It's false!

Stylesheet produced by PEAR::HTML_CSS package is put between style html tags in line 12.

Javascript is put between script html tags in line 17.

In line 24, we produces all the html code necessary to display the progress meter.

Finally, the line 25 makes it happen. This display the horizontal progress bar and run it from 0% to 100%, one percent step by step.

Of course, in this example there isn't anything the user can do, so let's create a more complex example.

Prev Up Next
Getting Started Getting Started Progress Handler

Documentation generated on Sun, 12 Sep 2004 20:22:37 +0200 by phpDocumentor 1.3.0RC3