-
- //Form.php
-
- class form {
-
- var $layout=true;///是否使用表格版面配置
-
- var $action;//表單要提交到的URL
-
- var $method;
-
- var $enctype="";
-
- var $name="";
-
- var $id="";
-
- var $class="";
-
-
- function form($action,$method ="POST"){ //透過建構子初始化成員變數
-
- $this->action=$action;
-
- $this->method=$method;
-
- }
-
-
- function form_start(){
-
- $text="
|
n";
$text.="n";
}else {
$text="n";
}
return $text;
}
}
}
//文字方塊函數
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;
;
;
;
;
;
}
//密碼框函數
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;
}
//隱藏域函數
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;
}
//檔案域函數
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;
}
// 建構子
$i=0;
$text=array();
foreach ($label如$id=>$value){
$text[$i]="";
$text[$i].="";
$i ;
}
$label=$this->form_label($label_name,$label_for);
$form_item=$this->form_item($label, $text);
return $form_item;
}
//單選框函數
function form_radio($name,$label=array( ),$label_name,$label_for=""){
$i=0;
$text=array();
foreach ($label as $id= >$value){
$text[$i]="";
$text[$i].="";
$i ;
}
$label=$this->form_label($label_name,$label_for);
$form_item=$this->form_item($label,$text);
return $form_item;
}
//下拉式選單函數
function form_select($id,$name,$options=array(), $selected=false,$label_name,$label_for,$onchange=""){
if($onchange! ==""){
$text="";
$label=$this->form_label($label_name,$label_for);
$form_item=$this-> form_item($label,$text);
return $form_item;
}
//多選列表函數
function form_selectmul($id, $name,$size,$options=array() ,$label_name,$label_for){
$text=" n";
foreach ($options as $value=>$key){
$text.="tn";
}
$text.="n";
$label=$this->form_label($label_name, $label_for);
$form_item=$this->form_item($label,$text);
return $form_item;
}
/ /按鈕函數
function form_button($id,$name,$type,$value,$onclick=""){
$text="
if($onclick! ==“”){
$text.=" onclick='{$onclick}'";
}
$text.=">".$value;
$text.="n";
if($this->佈局== true){
$form_item="nt |
{$text} | n
n";
}else {
$form_item=$text;
}
return $form_item;
> // 文字域函數
function form_textarea($id,$name,$cols,$rows,$label_name,$label_for,$value=""){
$text=" n";
$label=$this->form_label($label_name,$label_for);
$form_item=$this->form_item($label,$text);
return $form_item;
}
//文字標籤函數
function form_label($text,$for){
if($for! =="") {
$label="";
}else {
$label =$text.":";
}
return $label;
}
函數form_item($form_label,$form_label,$form) {
switch ($this->layout){
case true:
$text="n" ;
$text. ="t";
$text.=$form_label;
$text.="
| n";
$text.="t";
$text.=$form_text;
$text.=" td>n";
$text .="
|
n";
中斷;
case false:
$text= $form_label;
$text.=$ form_text;
線;
}
return $text;
}
echo $this->form_start();
foreach ($form_item as $item){
echo $item;
}
echo $this->form_end();
}
}
;
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
作者最新文章
-
2024-10-22 09:46:29
-
2024-10-13 13:53:41
-
2024-10-12 12:15:51
-
2024-10-11 22:47:31
-
2024-10-11 19:36:51
-
2024-10-11 15:50:41
-
2024-10-11 15:07:41
-
2024-10-11 14:21:21
-
2024-10-11 12:59:11
-
2024-10-11 12:17:31