PHP Classes
elePHPant
Icontem

File: class_form.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Edwin F. Sturt  >  JavaScript in PHP  >  class_form.php  >  Download  
File: class_form.php
Role: Auxiliary script
Content type: text/plain
Description: Class File
Class: JavaScript in PHP
Generate JavaScript for validation of HTML forms
Author: By
Last change:
Date: 3 years ago
Size: 5,520 bytes
 

Contents

Class file image Download
<?php
define
('T',"text");
define('P',"password");
define('C',"checkbox");
define('R',"radio");
define('H', "hidden");
define('B', "button");
define('S', "submit");
define('FI', "file");
define("JS1","onblur");
define("JS2","onchange");
define("JS3","onfocus");
define("JS4","onreset");
define("JS5","onselect");
define("JS6","onsubmit");
define("JS7","onkeydown");
define("JS8","onkeypress");
define("JS9","onkeyup");
define("JS10","onclick");
      

                function
input($TYPE="",$POST_NAME="",$VALUE="",$CLASS="",$ID="",$JS="JS1",$JS_value="",$size=0)
                {
                      
$OUT="<td><input type=\"$TYPE\" name=\"$POST_NAME\" size=\"$size\" value=\"$VALUE\" $JS=\"$JS_value\" class=\"$CLASS\" id=\"$ID\" /></td>\r\n";
                       echo
$OUT;
                }
               
                function
start_form($name="", $method="", $action="",$enc="multipart/form-data",$JS="",$JS_value="")
                {
                    echo
"<form name=\"$name\" autocomplete=\"off\" enctype=\"$enc\" method=\"$method\" action=\"$action\" $JS=\"$JS_value\" >\r\n";
                }
               

                function
end_form()
                {
                    echo
"</form>\r\n";
                   
                   
                }
                function
option_start($POST_NAME="",$VALUE="",$CLASS="",$ID="",$JS="default",$JS_value="--")
                {
                      
                        echo
"<td><select name=\"$POST_NAME\" $JS=\"$JS_value\">
                       
                       <option>
$VALUE</option>
                        "
;
                       
                }
                function
option_end()
                {
                    echo
"</select></td>";
                }
               
                function
option_list($values)
                {
                   
$value= str_replace(",","</option><option>",$values);
                   
$str= "$value";
                    return
$str;
                }
                           
                function
add_space($num=1)
                {
                  for (
$i = 0; $i < $num; $i++)
                    echo
"&nbsp;\r\n";
                }
               
                function
address_box($name="",$cols="",$row="",$value="",$id="",$JS="",$JS_value="")
                {

                  echo
"<td><textarea name=\"$name\" cols=\"$cols\" rows=\"$row\" id=\"$id\" $JS=\"$JS_value\">$value</textarea></td>\r\n";

                }
               
               
// Html Section
               
               
function page_head($title="",$encoding="utf-8")
                {
                    echo
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n";
                    echo
"<html>\r\n";
                    if(
$title=="")
                    {
                        echo
"<head><title>".COMPANY."</title>\r\n";
                    } else {
                            echo
"<head><title>$title</title>\r\n";
                    }
                                 
                    echo
"<meta http-equiv=\"Content-type\" content=\"text/html\"; charset=\"$encoding\">\r\n";
                  
               
                }
                function
body_elements($bgcolor="white", $font="", $fontsize="10px", $color="black",$weight="normal")
                {
                   
                    echo
"\r\n<body style=\"background: $bgcolor;font-family: $font;font-weight: $weight;font-size: $fontsize;color: $color;\">\r\n";
                }
               
               
                function
end_page()
                {
                    echo
"\r\n</body>\r\n</html>\r\n";
                }
                   
                function
_link_js($path="",$type="")
                {
                    echo
"<script src=\"$path\" type=\"$type\" ></script>\r\n";
                }
   
                function
_link_stylesheet($path="",$type="")
                {
                    echo
"<link rel=\"stylesheet\" href=\"$path\" type=\"$type\" >";
                }
               
                function
label($value="",$cols="1",$width="",$color="",$font_size="12px",$align="")
                {
                    echo
"<td align=\"$align\" colspan=\"$cols\" style=\"color:$color;font-size:$font_size;\">$value</td>\r\n";
                }
   
                function
readonly($name="",$label="", $value="",$id="default")
                {
                     echo
"<td>$label : </td><td>
                        <input type=\"text\" name=\"
$name\" value=\"$value\" readonly=\"\" id=\"$id\"/>";
                }
                    function
br($num=1)
                {
                    for (
$i = 0; $i < $num; $i++)
                    echo
"<br />\r\n";
   
                }
                   function
new_table($width="",$border="",$cellpadding="",$cellspacing="", $align="")
                {
                    echo
"<table border=\"$border\" width=\"$width\" align=\"$align\" cellpadding=\"$cellspacing\" cellspacing=\"$cellpadding\" >\r\n";
                }
   
                function
table_end()
                {
                   
                    echo
"</table>\r\n";
                }
               
                function
row($val)
                {
                    if(
$val==1)
                    {
                        echo
"<tr>\r\n";
                    } else {
                        echo
"</tr>\r\n";
                    }
                }

            
?>