OOhForms

Manual

OOhForms are part of the PHPlib-Mini-Framework (Examples from KUSKUS)

New form:

require($_PHPLIB["libdir"]."oohforms.inc");
$fo = new form;                   // create a form object for form
$fo->add_element(array("type"=>"select",
          "name"=>"f_person_gender",
          "valid_regex"=>"^[a-z]*$",
          "valid_e"=>"",
          "options"=>array(array("label"=>"K. Anrede","value"=>"0"),
          		   array("label"=>"Herr","value"=>"1"),
          		   array("label"=>"Frau","value"=>"2")
          ),
          "size"=>1,
          "value"=>$f_person_gender));

Submit

  $fo->add_element(array("type"=>"submit",
          "name"=>"submit",
          "value"=>"Abschicken"));

Checkbox

// which kind of calculation?
reset($picture_calculate_type);
unset($t);
foreach($picture_calculate_type AS $key => $val){
  if (is_array($calculation_type)){
   if (in_array($key, $calculation_type))
     $t[] = $key;
  } else {
   if (($calculation_type & $key) == $key)
     $t[]= $key;
  
  }
}
  $fo->add_element(array("type"=>"checkbox",
          "name"=>"calculation_type",
          "value"=>$t,
          "multiple"=>1)); 

Hidden

  $fo->add_element(array("type"=>"hidden",
          "name"=>"selfcall",
          "value"=>"yes"));

Radio

name

val

extrahtml (will be displayed with leading space)

Textarea

rows

cols

wrap

extrahtml (will be displayed with leading space)

Text

$fo->add_element(array("type"=>"text",
          "name"=>"f_person_title",
          "valid_regex"=>"^[a-z]*$",
          "valid_e"=>"Bitte nur Buchstaben beim Titel des Ansprechpartners<br>",
          "size"=>12,
          "maxlength"=>60,
          "icase"=>1,
          "value"=>$f_person_title));

Display form

// start
// OOf mainform...                                    
  $fo->start("", "GET", $PHP_SELF, "", "msgform");                  // Start displaying form
 
// display element:
$fo->show_element("submit");    // Show submit
 
// display multiple elements:
$i=1;
reset($picture_calculate_type);
foreach($picture_calculate_type AS $key => $val){
   if ($i++ % 2 == 1)
    echo "<span style=\"font-size:8pt; background-color: #D1D1D1\">";
   else
    echo "<span style=\"font-size:8pt; background-color: #F4F4F4\">";
   $fo->show_element("calculation_type", $key);
   echo " ".$val."</span>\n";
}
 
// finish:
$fo->finish();                     // Finish form
 
Nach oben
php/oohforms.txt · Zuletzt geändert: 2024/02/29 13:36 von 127.0.0.1
chimeric.de = chi`s home Creative Commons License Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0
DFmW2CEce3htPL1uNQuHUVu4Tk6WXigFQp   Dogecoin Donations Accepted Here    DFmW2CEce3htPL1uNQuHUVu4Tk6WXigFQp  DFmW2CEce3htPL1uNQuHUVu4Tk6WXigFQp