PHP Classes

File: FORM

Recommend this page to a friend!
  Classes of li king   FORM   FORM   Download  
File: FORM
Role: Class source
Content type: text/plain
Description: add form
Class: FORM
Generate HTML forms
Author: By
Last change: FORM,Example
Date: 21 years ago
Size: 3,384 bytes
 

Contents

Class file image Download
<?php
/**
* @author Zigang Li,Nickname:webdi
* @copyright http://www.uplinux.com,webdi - distributed under the LGPL
* @version 0.1 - 2003/1/3
*/
//--use example:
/****************
//<?php
//--test.php
//--test form
require_once("is_form.class.php");//this is the form class file
 
$new=new FORM("testform","test.php","post");
$newform=$new->is_form("testform","test.php","post");
$newform.=$new->add_input("text","name","","8",1,"","#f3f3f3",1,"","blue","");
$newform.=$new->add_textarea("mytext","Please write...",12,20,
        "#FFCCFF",1,"");
$select_name=array("haha","adfsad","asdsadfd");
$newform.=$new->add_select("IS_selset",$select_name,"#ffffff",
        "solid",3);
$va=array("dfasdf","asdad","asdfasdfdfddfdfdf");
$newform.=$new->add_input("radio","radioname",$va,"8",3,"","#FF99CC",1,"","blue","");

$newform.=$new->end_form();
echo $newform;

?>

***********************************/

class FORM {
    var
$formname;
    var
$action;
    var
$method;
    var
$type;
    var
$size;
    var
$name;
    var
$value;
    var
$class;
    var
$style_color_bg;
    var
$style_boder;
    var
$style_double_color;
    var
$onMouseover_bgcolor;
    var
$onMouseOut_bgcolor;
    var
$border_style;
    var
$num;
    var
$textname;
   
//var $select_value=array();
   
var $select_name=array();

    function
FORM($formname="IS_form",$action="",$method="post"){
       
$this->is_form($formname,$action,$method);
    }

    function
is_form($formname="IS_form",$action="",$method="post"){
       
$html="<form name=\"$formname\" action=\"$action\" method=\"$method\">";
        return
$html;
    }

    function
add_input($type="",$name="",$value="",
       
$size="8",$num=1,$class="",$style_color_bg="#ffffff",
       
$style_boder=1,$style_double_color="",$onMouseover_bgcolor="",
       
$onMouseOut_bgcolor=""){
       
        if (
$type=="radio"){
           
$radiois="";
        }else{
           
$radiois="size=\"$size\" class=\"$class\" style=\"background-color:$style_color_bg; border: $style_boder double $style_double_color\" onMouseOver = \"this.style.backgroundColor = '$onMouseover_bgcolor'\" onMouseOut = \"this.style.backgroundColor = '$onMouseOut_bgcolor'\"";
        }
        if (
$num>1){
            for (
$n=0;$n<$num;$n++){
               
$html.="<input type=\"$type\" name=\"$name\" value=\"$value[$n]\" $radiois>$value[$n] ";
            }
        }else{
           
$html.="<input type=\"$type\" name=\"$name\" value=\"$value\" $radiois>";
        }
        return
$html;
    }
    function
add_select($name="IS_selset",$select_name,$style_color_bg="#ffffff",
       
$border_style="solid",$num){
       
$html="<select name=$name style='color: #6699FF; background-color: $style_color_bg; border-style: $border_style; border-width: 1'>";
        for (
$i=0;$i<$num;$i++){
           
$html.="<OPTION value=\"$select_name[$i]\">$select_name[$i]</OPTION>";
        }
       
$html.="</select>";
        return
$html;
    }
    function
add_checkbox($name="IS_checkbox",$value,$num){
        for (
$i=0;$i<$num;$i++){
           
$html.="<INPUT TYPE=\"checkbox\" NAME=\"{$name}_{$i}\" value=\"$value[$i]\">$value[$i] ";
        }
        return
$html;
    }
    function
add_textarea($textname="IS_text",$textvalue="",$rows=12,$cols=20,
       
$style_color_bg="#ffffff",$style_boder=1,$style_double_color=""){
       
$html="<textarea name=\"$textname\" rows=\"$rows\" cols=\"$cols\" style=\"background-color:$style_color_bg; border: $style_boder double $style_double_color\">$textvalue</textarea>";
        return
$html;
    }
    function
end_form(){
        return
"</form>";
    }
}

?>