-
- form.php
- Class Form {
- var $layout =true;//whether to use table layout
- var $action;//URL to which the form is to be submitted
- var $method;
- var $enctype = "";
- var $name = "";
- var $id = "";
- var $class = "";
- function form ($action, $method = "POST") {//Initialize member variable with constructor function
- $this->action= $action;
- $this->method= $method;
- }
- function Form_start () {
- $text = "\ n";
- }else {
- $text = "\ n";
- }
- return $text;
- }
- text box functions
- function Form_text ($name, $id, $label _name, $label _for, $value = "") {
- $text = "
- $text. = "Id=\" {$id}\ "";
- if (Isset ($value)) {
- $text. = "Value=\" {$value}\ "";
- }
- $text. = "/>\n";
- $label = $this->form_label ($label _name, $label _for);
- $form _item= $this->form_item ($label, $text);
- return $form _item;
- }
- Password box function
- function form_passwd ($name, $id, $label _name, $label _for, $value = "") {
- $text = "
- $text. = "Id=\" {$id}\ "";
- if (Isset ($value)) {
- $text. = "Value=\" {$value}\ "";
- }
- $text. = "/>\n";
- $label = $this->form_label ($label _name, $label _for);
- $form _item= $this->form_item ($label, $text);
- return $form _item;
- }
- hidden field functions
- function Form_hidden ($name, $id, $label _name, $label _for, $value = "") {
- $text = "
- if (Isset ($value)) {
- $text. = "Value=\" {$value}\ "";
- }
- $text. = "/>\n";
- $label = $this->form_label ($label _name, $label _for);
- $form _item= $this->form_item ($label, $text);
- return $form _item;
- }
- File field functions
- function Form_file ($name, $id, $label _name, $label _for, $size = "") {
- $text = "
- $text. = "Id=\" {$id}\ "";
- if (Isset ($size)) {
- $text. = "Size=\" {$size}\ "";
- }
- $text. = "/>\n";
- $label = $this->form_label ($label _name, $label _for);
- $form _item= $this->form_item ($label, $text);
- return $form _item;
- }
- check box function
- function Form_checkbox ($name, $label =array (), $label _name, $label _for= "") {
- $i = 0;
- $text =array ();
- foreach ($label as $id = = $value) {
- $text [$i]=]";
- $text [$i].= "{$value}";
- $i + +;
- }
- $label = $this->form_label ($label _name, $label _for);
- $form _item= $this->form_item ($label, $text);
- return $form _item;
- }
- Radio Box function
- function Form_radio ($name, $label =array (), $label _name, $label _for= "") {
- $i = 0;
- $text =array ();
- foreach ($label as $id = = $value) {
- $text [$i]=]";
- $text [$i].= "{$value}";
- $i + +;
- }
- $label = $this->form_label ($label _name, $label _for);
- $form _item= $this->form_item ($label, $text);
- return $form _item;
- }
- Drop-down menu function
- function Form_select ($id, $name, $options =array (), $selected =false, $label _name, $label _for, $onchange = "") {
- if ($onchange!== "") {
- $text = "\ n "; } else{$text = "\ n ";
- }
- foreach ($options as $value = = $key) {
- if ($selected = = $value) {
- $text. = "\ t{$key}\n ";
- }elseif ($selected ===false) {
- $text. = "\ t{$key}\n ";
- }
- }
- $text. = "";
- $label = $this->form_label ($label _name, $label _for);
- $form _item= $this->form_item ($label, $text);
- return $form _item;
- }
- Multi-select list function
- function Form_selectmul ($id, $name, $size, $options =array (), $label _name, $label _for) {
- $text = "\ n "; foreach ($options as $value = = $key) {$text. = "\ t{$key}\n "; } $text. = "\ n ";
- $label = $this->form_label ($label _name, $label _for);
- $form _item= $this->form_item ($label, $text);
- return $form _item;
- }
- button function
- function Form_button ($id, $name, $type, $value, $onclick = "") {
- $text = "
- if ($onclick!== "") {
- $text. = "onclick= ' {$onclick} '";
- }
- $text. = ">". $value;
- $text. = "
\ n ";
- if ($this->layout==true) {
- $form _item= "
|