HTML_Select
[ class tree: HTML_Select ] [ index: HTML_Select ] [ all elements ]

Source for file grouped.php

Documentation is available at grouped.php

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  3.         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  4. <html xmlns="http://www.w3.org/1999/xhtml">
  5.  <head>
  6.   <title>HTML_Select demo: option groups</title>
  7.  </head>
  8.  <body>
  9.   <form method="get" action="#">
  10.    <p>
  11. <label for="color">Select some colors:</label>
  12. <?php
  13. /**
  14.  * Demo for HTML_Select with options groups
  15.  */
  16. //you do *not* need the following line!
  17.     dirname(__FILE__'/../'
  18.     . PATH_SEPARATOR . get_include_path()
  19. );
  20.  
  21. require_once 'HTML/Select.php';
  22.  
  23. //key is used as label, value as <option value="">.
  24. $colors = array(
  25.     'dark' => array(
  26.         'black' => '#000000',
  27.         'dark grey' => '#666666',
  28.     ),
  29.     'light' => array(
  30.         'white' => '#FFFFFF',
  31.         'yellow' => '#FFFF00',
  32.         'light grey' => '#DDDDDD',
  33.     ),
  34.     'colorful' => array(
  35.         'red'    => '#FF0000',
  36.         'green'  => '#00FF00',
  37.         'blue'   => '#0000FF',
  38.         'orange' => '#FF8000',
  39.     )
  40. );
  41.  
  42. //multiselect with height of 12 lines
  43. $hs = new HTML_Select('color'12true);
  44.  
  45. //preselected values are dark grey and red
  46. $hs->loadArray($colorsarray('#666666''#FF0000'));
  47.  
  48. echo $hs->toHtml();
  49.  
  50. ?>
  51.    </p>
  52.  
  53.    <p>
  54. <label for="year">Select a year:</label>
  55. <?php
  56. /**
  57.  * Demo for HTML_Select with options groups
  58.  */
  59.  
  60. $years = array(
  61.     'seventies' => range(19701979),
  62.     'eighties'  => range(19801989),
  63.     'nineties'  => range(19901999)
  64. );
  65.  
  66. //multiselect with height of 12 lines
  67. $hs = new HTML_Select('year');
  68.  
  69. //preselected year is 1982
  70. $hs->loadValueArray($years1982);
  71.  
  72. echo $hs->toHtml();
  73.  
  74. ?>
  75.    </p>
  76.   </form>
  77.  </body>
  78. </html>

Documentation generated on Mon, 11 Mar 2019 15:47:41 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.