Location: PHPKode > scripts > 3SS Data Description Form > 3ss-data-description-form/threessddf.class.php
<?php
class threessDDF
{
    ///////////////////////////////////////////////
    //
    //    3 Service Solution
    //    http://www.3servicesolution.com/
    //    Author: Brant Messenger
    //
    //    COPYRIGHT:
    //    http://creativecommons.org/licenses/by-sa/2.0/
    //
    //    LOCATION:
    //    http://www.3servicesolution.com/_classes/threessddf.class.inc
    //
    //    VERSION: 4.6.0
    //
    ///////////////////////////////////////////////

    var $db;
    var $table;
    var $size;
    var $action;
    var $required;    
    var $desc;
    var $data;
    var $symbol;

    function threessDDF($db,$table,$size,$action,$setRequired=False)
    {
        
        $this->db = $db;
        $this->table = $table;
        $this->inputSize = $size;
        $this->action = $action;
        $this->required = $setRequired;
        
        $this->desc = $this->db->get_results("DESC $this->table");
        
        $this->symbol = "&#36;";
        
        $this->_initialize();
    }
    
    function _initialize()
    {
        
        for($i=0;$i<count($this->desc);$i++)
        {
            /*
            [Field] => id
            [Type] => int(11)
            [Null] => 
            [Key] => PRI
            [Default] => 
            [Extra] => auto_increment
            */

            /*
            * FIELD NAME & TITLE
            */
            $this->data[$i]->name = $this->desc[$i]->Field;
            $this->data[$i]->title = ucwords(str_replace(array("_","-")," ",$this->data[$i]->name));
            
            
            /*
            * DATA TYPE
            */
            $dataInfo = explode("(",$this->desc[$i]->Type);
            $this->data[$i]->type = (STRING) $dataInfo[0];
            
            /*
            * DATA TYPE VALUE
            */
            if (count($dataInfo) > 1) $this->data[$i]->data = (INT) str_replace(")","",$dataInfo[1]);
            else $this->data[$i]->data = NULL;
            
            /*
            * INPUT MAX LENGTH
            */
            if (is_int($this->data[$i]->data) && $this->data[$i]->data > 0) $this->data[$i]->inputMaxlength = $this->data[$i]->data;
            else $this->data[$i]->inputMaxlength = NULL; 

            /*
            * IS FIELD NULL
            */
            $this->data[$i]->null = $this->desc[$i]->Null;

            /*
            * IS FIELD A KEY FIELD
            */
            $this->data[$i]->key = $this->desc[$i]->Key;
            
            /*
            * SET DEFAULT VALUE
            */
            $this->data[$i]->default = $this->desc[$i]->Default;
            
            /*
            * SET EXTRA FIELD INFORMATION
            */
            $this->data[$i]->extra = $this->desc[$i]->Extra;
            
            /*
            * EXTEND OBJECT
            */            

            if (isset($this->action[$this->data[$i]->name])) $this->data[$i]->value = $this->action[$this->data[$i]->name];
            else $this->data[$i]->value = $this->data[$i]->default;
            
            if ($this->inputSize > $this->data[$i]->inputMaxlength) $this->data[$i]->inputSize = $this->data[$i]->inputMaxlength;
            else $this->data[$i]->inputSize = $this->inputSize;

            if ($this->required == True && $this->data[$i]->null != 'YES') $this->data[$i]->required = $this->required;
            else $this->data[$i]->required = NULL;   
                     
            
            /*
            * FORM ELEMENTS
            */
            $this->data[$i]->formHidden = '<input type="hidden" name="'.$this->data[$i]->name.'" id="'.$this->data[$i]->name.'" value="'.$this->data[$i]->value.'" />'."\n";
            $this->data[$i]->formUpload = '<input type="file" enctype="multipart/form-data" name="'.$this->data[$i]->name.'" />';

            switch($this->data[$i]->type)
            {
                case "decimal":
                    if (isset($this->action[$this->data[$i]->name]))
                    {
                        if (is_array($this->action[$this->data[$i]->name]) && count($this->action[$this->data[$i]->name])) $value = implode('.',$this->action[$this->data[$i]->name]);
                        else $value = $this->action[$this->data[$i]->name];
                        
                        if (strlen($value) == 1) $this->data[$i]->value = "";
                        else $this->data[$i]->value = $value;

                    }

                    $max = explode(",",$this->data[$i]->data);
                    $maxSize = $max[0];

                    $aDecimalSize = explode(' ',$max[1]);

                    $decimalSize = $aDecimalSize[0];

                    $this->data[$i]->inputSize = $maxSize - $decimalSize;
                    $values = explode(".",$this->data[$i]->value);
                    
                    if ($maxSize == 5 && $decimalSize == 2) $symbol = '$ ';
                    else $symbol = Null;
                    
                    
                    
                    if ($this->data[$i]->required != NULL)
                    {
                        $this->reqArray[] = $this->data[$i]->name."[0]";
                        $this->numArray[] = $this->data[$i]->name."[0]";
                        
                        $this->reqArray[] = $this->data[$i]->name."[1]";
                        $this->numArray[] = $this->data[$i]->name."[1]";
                        $this->minNumArray[] = $this->data[$i]->name."[1]";
                        
                    }
                    else
                    {
                        $this->numArray[] = $this->data[$i]->name."[0]";
                        
                        $this->numArray[] = $this->data[$i]->name."[1]";
                        $this->minNumArray[] = $this->data[$i]->name."[1]";
                    }
                     
                    $this->data[$i]->formCurrency = $this->symbol.'<input type="text" id="'.$this->data[$i]->name.'[0]" name="'.$this->data[$i]->name.'[0]" size="'.$this->data[$i]->inputSize.'" maxlength="'.$this->data[$i]->inputMaxlength.'" value="'.$values[0].'" />.<input type="text" id="'.$this->data[$i]->name.'" name="'.$this->data[$i]->name.'[1]" size="'.$decimalSize.'" maxlength="'.$decimalSize.'" value="'.$values[1].'" />';
                    $this->data[$i]->form = '<input type="text" id="'.$this->data[$i]->name.'[0]" name="'.$this->data[$i]->name.'[0]" size="'.$this->data[$i]->inputSize.'" maxlength="'.$this->data[$i]->inputMaxlength.'" value="'.$values[0].'" />.<input type="text" name="'.$i.'[1]" size="'.$decimalSize.'" maxlength="'.$decimalSize.'" value="'.$values[1].'" />';

                break;
                
                
                
                case "date":
                    if (isset($this->action[$this->data[$i]->name]) && is_array($this->action[$this->data[$i]->name]))
                    {
                        if ($this->action[$this->data[$i]->name]['YEAR'] == "" || $this->action[$this->data[$i]->name]['MONTH'] == "" || $this->action[$this->data[$i]->name]['DAY'] == "") $value = NULL;
                        else $value = $this->action[$this->data[$i]->name]['YEAR']."-".$this->action[$this->data[$i]->name]['MONTH']."-".$this->action[$this->data[$i]->name]['DAY'];
                        
                        $this->data[$i]->value = $value;
                    }

                    $values = explode("-",$this->data[$i]->value);
                    
                    $values['MONTH'] = $values[1];
                    $values['DAY'] = $values[2];
                    $values['YEAR'] = $values[0];
                    
                    
                    
                    if ($this->data[$i]->required != NULL)
                    {
                        $this->reqArray[] = $this->data[$i]->name."[MONTH]";
                        $this->numArray[] = $this->data[$i]->name."[MONTH]";
                        $this->minNumArray[] = $this->data[$i]->name."[MONTH]";
                        
                        $this->reqArray[] = $this->data[$i]->name."[DAY]";
                        $this->numArray[] = $this->data[$i]->name."[DAY]";
                        $this->minNumArray[] = $this->data[$i]->name."[DAY]";
                        
                        $this->reqArray[] = $this->data[$i]->name."[YEAR]";
                        $this->numArray[] = $this->data[$i]->name."[YEAR]";
                        $this->minNumArray[] = $this->data[$i]->name."[YEAR]";
                        
                    }
                    else
                    {
                        $this->numArray[] = $this->data[$i]->name."[MONTH]";
                        $this->minNumArray[] = $this->data[$i]->name."[MONTH]";
                        
                        $this->numArray[] = $this->data[$i]->name."[DAY]";
                        $this->minNumArray[] = $this->data[$i]->name."[DAY]";
                        
                        $this->numArray[] = $this->data[$i]->name."[YEAR]";
                        $this->minNumArray[] = $this->data[$i]->name."[YEAR]";
                    }
                    
                    $this->data[$i]->form = '<input type="text" id="'.$this->data[$i]->name
                    .'[MONTH]" name="'.$this->data[$i]->name
                    .'[MONTH]" size="2" maxlength="2" value="'.$values['MONTH']
                    .'" /> / <input type="text" id="'.$this->data[$i]->name
                    .'[DAY]" name="'.$this->data[$i]->name
                    .'[DAY]" size="2" maxlength="2" value="'.$values['DAY']
                    .'" /> / <input type="text" id="'.$this->data[$i]->name
                    .'[YEAR]" name="'.$this->data[$i]->name
                    .'[YEAR]" size="4" maxlength="4" value="'.$values['YEAR'].'" />';
                    
                break;
                
                
                
                case "datetime":
                    if (isset($this->action[$this->data[$i]->name]) && is_array($this->action[$this->data[$i]->name]))
                    {
                        $valueDate = $this->action[$this->data[$i]->name]['YEAR']."-".$this->action[$this->data[$i]->name]['MONTH']."-".$this->action[$this->data[$i]->name]['DAY'];
						$valueTime = $this->action[$this->data[$i]->name]['HOUR'].":".$this->action[$this->data[$i]->name]['MINUTE'].":".$this->action[$this->data[$i]->name]['SECOND'];
                        $this->data[$i]->value = $valueDate.' '.$valueTime;

                    }

                    $breakArray = explode(" ",$this->data[$i]->value);
                    
                    $valuesDateArray = explode("-",$breakArray[0]);
                    $valuesTimeArray = explode(":",$breakArray[1]);
                    
                    $values['MONTH'] = $valuesDateArray[1];
                    $values['DAY'] = $valuesDateArray[2];
                    $values['YEAR'] = $valuesDateArray[0];
                    
                    $values['HOUR'] = $valuesTimeArray[0];
                    $values['MINUTE'] = $valuesTimeArray[1];
                    $values['SECOND'] = $valuesTimeArray[2];
                    
                    
                    
                    if ($this->data[$i]->required != NULL)
                    {
                        $this->reqArray[] = $this->data[$i]->name."[MONTH]";
                        $this->numArray[] = $this->data[$i]->name."[MONTH]";
                        $this->minNumArray[] = $this->data[$i]->name."[MONTH]";
                        
                        $this->reqArray[] = $this->data[$i]->name."[DAY]";
                        $this->numArray[] = $this->data[$i]->name."[DAY]";
                        $this->minNumArray[] = $this->data[$i]->name."[DAY]";
                        
                        $this->reqArray[] = $this->data[$i]->name."[YEAR]";
                        $this->numArray[] = $this->data[$i]->name."[YEAR]";
                        $this->minNumArray[] = $this->data[$i]->name."[YEAR]";
                        
                        $this->reqArray[] = $this->data[$i]->name."[HOUR]";
                        $this->numArray[] = $this->data[$i]->name."[HOUR]";
                        $this->minNumArray[] = $this->data[$i]->name."[HOUR]";
                        
                        $this->reqArray[] = $this->data[$i]->name."[MINUTE]";
                        $this->numArray[] = $this->data[$i]->name."[MINUTE]";
                        $this->minNumArray[] = $this->data[$i]->name."[MINUTE]";
                        
                        $this->reqArray[] = $this->data[$i]->name."[SECOND]";
                        $this->numArray[] = $this->data[$i]->name."[SECOND]";
                        $this->minNumArray[] = $this->data[$i]->name."[SECOND]";
                        
                    }
                    else
                    {
                        $this->numArray[] = $this->data[$i]->name."[MONTH]";
                        $this->minNumArray[] = $this->data[$i]->name."[MONTH]";
                        
                        $this->numArray[] = $this->data[$i]->name."[DAY]";
                        $this->minNumArray[] = $this->data[$i]->name."[DAY]";
                        
                        $this->numArray[] = $this->data[$i]->name."[YEAR]";
                        $this->minNumArray[] = $this->data[$i]->name."[YEAR]";
                        
                        $this->numArray[] = $this->data[$i]->name."[HOUR]";
                        $this->minNumArray[] = $this->data[$i]->name."[HOUR]";
                        
                        $this->numArray[] = $this->data[$i]->name."[MINUTE]";
                        $this->minNumArray[] = $this->data[$i]->name."[MINUTE]";
                        
                        $this->numArray[] = $this->data[$i]->name."[SECOND]";
                        $this->minNumArray[] = $this->data[$i]->name."[SECOND]";
                    }
                    
                    $this->data[$i]->form = '<input type="text" id="'.$this->data[$i]->name.'[MONTH]" name="'.$this->data[$i]->name.'[MONTH]" size="2" maxlength="2" value="'.$values['MONTH'].'" /> / <input type="text" id="'.$this->data[$i]->name.'[DAY]" name="'.$this->data[$i]->name.'[DAY]" size="2" maxlength="2" value="'.$values['DAY'].'" /> / <input type="text" id="'.$this->data[$i]->name.'[YEAR]" name="'.$this->data[$i]->name.'[YEAR]" size="4" maxlength="4" value="'.$values['YEAR'].'" />';
                    $this->data[$i]->form .= '<input type="text" id="'.$this->data[$i]->name.'[HOUR]" name="'.$this->data[$i]->name.'[HOUR]" size="2" maxlength="2" value="'.$values['HOUR'].'" /> / <input type="text" id="'.$this->data[$i]->name.'[MINUTE]" name="'.$this->data[$i]->name.'[MINUTE]" size="2" maxlength="2" value="'.$values['MINUTE'].'" /> / <input type="text" id="'.$this->data[$i]->name.'[SECOND]" name="'.$this->data[$i]->name.'[SECOND]" size="4" maxlength="4" value="'.$values['SECOND'].'" />';
                    
                break;
                
                
                
                case "tinyint":
                case "smallint":
                case "int":
                case "bigint":
                case "mediumint":
                    
                    if ($this->data[$i]->required != NULL)
                    {
                        $this->reqArray[] = $this->data[$i]->name;
                        $this->numArray[] = $this->data[$i]->name;
                    }
                    else
                    {
                        $this->numArray[] = $this->data[$i]->name;
                        $this->minNumArray[] = $this->data[$i]->name;
                    }

                    if ($this->data[$i]->value == '' && $this->data[$i]->default < 1) $this->data[$i]->form = '<input type="text" id="'.$this->data[$i]->name.'" name="'.$this->data[$i]->name.'" size="'.$this->data[$i]->inputSize.'" maxlength="'.$this->data[$i]->inputMaxlength.'" value="" />';
                    else if ($this->data[$i]->value == '') $this->data[$i]->form = '<input type="text" id="'.$this->data[$i]->name.'" name="'.$this->data[$i]->name.'" size="'.$this->data[$i]->inputSize.'" maxlength="'.$this->data[$i]->inputMaxlength.'" value="'.$this->data[$i]->default.'" />';
                    else $this->data[$i]->form = '<input type="text" id="'.$this->data[$i]->name.'" name="'.$this->data[$i]->name.'" size="'.$this->data[$i]->inputSize.'" maxlength="'.$this->data[$i]->inputMaxlength.'" value="'.$this->data[$i]->value.'" />';                

                break;
                
                case "char":
                    
                    
                    if ($this->data[$i]->required != NULL)
                    {
                        $this->reqArray[] = $this->data[$i]->name;
                        $this->aArray[] = $this->data[$i]->name;
                        $this->minAArray[] = $this->data[$i]->name;
                        
                    }
                    else
                    {
                        $this->aArray[] = $this->data[$i]->name;
                        $this->minAArray[] = $this->data[$i]->name;
                    }

                    $this->data[$i]->form = '<input type="text" id="'.$this->data[$i]->name.'" name="'.$this->data[$i]->name.'" size="'.$this->data[$i]->inputSize.'" maxlength="'.$this->data[$i]->inputMaxlength.'" value="'.$this->data[$i]->value.'" />';
                break;
                                
                case "varchar":
                    
                    
                    if ($this->data[$i]->required != NULL)
                    {
                        $this->reqArray[] = $this->data[$i]->name;
                        $this->aArray[] = $this->data[$i]->name;
                        if (strpos($this->data[$i]->name,'email') > -1) $this->eArray[] = $this->data[$i]->name;
                    
                    }
                    else
                    {
                        $this->aArray[] = $this->data[$i]->name;
                        if (strpos($this->data[$i]->name,'email') > -1) $this->eArray[] = $this->data[$i]->name;

                    }

                    $this->data[$i]->form = '<input type="text" id="'.$this->data[$i]->name.'" name="'.$this->data[$i]->name.'" size="'.$this->data[$i]->inputSize.'" maxlength="'.$this->data[$i]->inputMaxlength.'" value="'.$this->data[$i]->value.'" />';
                    $this->data[$i]->formPassword = '<input type="password" id="'.$this->data[$i]->name.'" name="'.$this->data[$i]->name.'" size="'.$this->data[$i]->inputSize.'" maxlength="'.$this->data[$i]->inputMaxlength.'" value="'.$this->data[$i]->value.'" />';
                    
                break;

                case "text":
                    
                    
                    if ($this->data[$i]->required != NULL)
                    {
                        $this->reqArray[] = $this->data[$i]->name;
                        $this->aArray[] = $this->data[$i]->name;
                        if (strpos($this->data[$i]->name,'email') > -1) $this->eArray[] = $this->data[$i]->name;

                    }
                    else
                    {
                        $this->aArray[] = $this->data[$i]->name;
                        if (strpos($this->data[$i]->name,'email') > -1) $this->eArray[] = $this->data[$i]->name;

                    }

                    if ($this->data[$i]->inputMaxlength != NULL) $this->data[$i]->form = '<input type="text" id="'.$this->data[$i]->name.'" name="'.$this->data[$i]->name.'" size="'.$this->data[$i]->inputSize.'" maxlength="'.$this->data[$i]->inputMaxlength.'" value="'.$this->data[$i]->value.'" />';
                    else $this->data[$i]->form = '<textarea cols="'.$this->inputSize.'" id="'.$this->data[$i]->name.'" name="'.$this->data[$i]->name.'">'.$this->data[$i]->value.'</textarea>';
                    
                break;
                
                
                case "set":
                    $aValues = explode(",",$this->data[$i]->data);
                    
                    
                    
                    $this->data[$i]->values = $values;

                    if (is_array($this->data[$i]->value)) $aCurrentValues = $this->data[$i]->value;
                    else $aCurrentValues = explode(",",$this->data[$i]->value);
                    
                    
                    $str = "";
                    for($ii=0;$ii<count($aValues);$ii++)
                    {
                        $vChecked = "";

                        for($iii=0;$iii<count($aCurrentValues);$iii++)
                        {
                            if ($aValues[$ii] == $aCurrentValues[$iii]) $vChecked = ' checked="checked"';
                        }
                        
                        $str .= '
                        <span nowrap="nowrap" style="white-space:nowrap;">
                            <input type="checkbox" id="'.$this->data[$i]->name.'[]" name="'.$this->data[$i]->name.'[]" value="'.$aValues[$ii].'"'.$vChecked.' />
                            '.$aValues[$ii].'</span>';
                    }
                    
                    
                    
                    if ($this->data[$i]->required != NULL)
                    {
                        $this->reqArray[] = $this->data[$i]->name;
                    }
                    
                    $this->data[$i]->form = $str;
                    
                    
                    
                    $this->data[$i]->value = implode(",",$aCurrentValues);
                    
                break;
                
                
                
                case "enum":
                    
                    $clean = str_replace(array(")","'"),"",$dataInfo[1]);
                    
                    $values = explode(",",$clean);
                    
                    $this->data[$i]->values = $values;
                    
                    if ($this->data[$i]->value == "" && $this->data[$i]->default != "") $this->data[$i]->value = $this->data[$i]->default;

                    $str = "";

                    foreach($values as $v)
                    {
                        if ($this->data[$i]->value == $v) $vChecked = ' checked="checked"';
                        else $vChecked = "";

                        $str .= ' <span nowrap="nowrap" style="white-space:nowrap;"><input type="radio" id="'.$this->data[$i]->name.'" name="'.$this->data[$i]->name.'" value="'.$v.'"'.$vChecked.' /> '.$v."</span>";
                    }
                    
                    
                    
                    if ($this->data[$i]->required)
                    {
                        $this->reqArray[] = $this->data[$i]->name;
                    }

                    $this->data[$i]->form = $str;
                    
                break;

            }
            
            
            if ($this->data[$i]->null == "YES" && $this->data[$i]->value == "") $this->data[$i]->sqlValue = $this->data[$i]->name." = NULL";
            elseif ($this->data[$i]->null != "YES" && $this->data[$i]->value == "") $this->data[$i]->sqlValue = $this->data[$i]->name." = '".$this->data[$i]->default."'";
            else $this->data[$i]->sqlValue = $this->data[$i]->name." = '".$this->escape($this->data[$i]->value)."'";            

        }
        
        
        
        
        
        
        $this->jsValidate = '

'.$this->returnValidation().'
    
var ns4 = (document.layers);
var ie4 = (document.all && !document.getElementById);
var ie5 = (document.all && document.getElementById);
var ns6 = (!document.all && document.getElementById);

function initialCap(s)
{
	var index;
	var tmpStr;
	var tmpChar;
	var preString;
	var postString;
	var strlen;

	tmpStr = s.toLowerCase();
	strLen = tmpStr.length;

	if (strLen > 0)
    {
		for (index = 0; index < strLen; index++)
        {
			if (index == 0)
            {
				tmpChar = tmpStr.substring(0,1).toUpperCase();
				postString = tmpStr.substring(1,strLen);
				tmpStr = tmpChar + postString;
			}
			else
            {
				tmpChar = tmpStr.substring(index, index+1);
				if (tmpChar == " " && index < (strLen-1))
                {
					tmpChar = tmpStr.substring(index+1, index+2).toUpperCase();
					preString = tmpStr.substring(0, index+1);
					postString = tmpStr.substring(index+2,strLen);
					tmpStr = preString + tmpChar + postString;
				}
			}
		}
	}
	return tmpStr;
}

function checkemail(str)
{
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i

	if (filter.test(str)) testresults=true;
	else testresults=false;

	return (testresults);
}

function checkForm (obj,reqArray,numArray,minNumArray,aArray,minAArray,eArray) 
{
    if (ns6 || ie5) 
    {
        var df = obj;
        var e = df.elements;
        var str = "";
        


        
        
        var requiredArray = reqArray;
        
        
        var numericArray = numArray;
        
        
        var minimumNumericArray = minNumArray;
        
        
        var alphaArray = aArray;
        
        
        var minimumAlphaArray = minAArray;
        
        
        var emailArray = eArray;




    	for(i=0;i<e.length;i++)
        {
            var oi = df.elements[i];
        	var n = oi.name;
            var nt = initialCap(n.replace("_"," "));
            var v = oi.value;
            var t = oi.type;
            var m = oi.getAttribute("maxlength");
   			var radioCheck = -1;

            var strOption = "[ "+nt+" ] SELECT OPTION";
            var strRequired = "[ "+nt+" ] REQUIRED";
            var strNumeric = "[ "+nt+" ] NUMERIC ONLY";
            var strAlphaNumeric = "[ "+nt+" ] ALPHA-NUMERIC ONLY";
            var strMinimumNumeric = "[ "+nt+" ] AT LEAST "+m+" NUMBERS";
            var strMinimumAlpha = "[ "+nt+" ] AT LEAST "+m+" CHARACTERS";            
            var strEmail = "[ "+nt+" ] NOT VALID";
            var strUpgrade = "Please UPGRADE your browser, before proceeding.";
            		
			switch(t)
            {
            


            	case "checkbox":
                


                
            	case "radio":
                  
                    var radios = e[n];
                    if (radioCheck === -1)
                    {
                    	for(ii=0;ii<radios.length;ii++)
                    	{
                    		if (radios[ii].checked) 
                    		{
			                    radioCheck++;
                            }
	                    }
                    
    	                if (radioCheck < 0)
        	            {
            		        alert(strOption);
		                    oi.focus();
		                    return false;
                    	}
                    }

                break;



                
                case "select-one":
                
                	if (requiredArray[i] == n && v < 1)
                    {
                    	alert(strOption);
                        oi.focus();
                        return false;
                    }

                break;



                
                case "password":



                case "textarea":
				case "text":

                    	for(ii=0;ii<requiredArray.length;ii++)
                        {
                        	if (requiredArray[ii] == n && v == "")
                            {
                                alert(strRequired);
                        		oi.focus();
                        		return false;
                            }

                        }
                        


                    	
                    	for(ii=0;ii<numericArray.length;ii++)
                        {
                        	if (numericArray[ii] == n && isNaN(v) == true)
                            {
                            	if (v != "")
                                {
	                                alert(strNumeric);
	                                oi.focus();
                                    oi.select();
	                                return false;
                                }
                            }
                        }                    	



                        
                    	for(ii=0;ii<minimumNumericArray.length;ii++)
                        {
                        	if (minimumNumericArray[ii] == n && v.length != m)
                            {
                            	if (v != "")
                                {                            
                                alert(strMinimumNumeric);
                                oi.focus();
                                oi.select();
                                return false;
                                }
                            }
                        }



                        
                    	for(ii=0;ii<emailArray.length;ii++)
                        {
                        	if (emailArray[ii] == n && checkemail(v) == false)
                            {
                            	if (v != "")
                                {                            
                                alert(strEmail);
                                oi.focus();
                                oi.select();
                                return false;
                                }
                            }
                        }



                        
                    	for(ii=0;ii<alphaArray.length;ii++)
                        {
                        	if (alphaArray[ii] == n && isNaN(v) == false)
                            {
                            	if (v != "")
                                {                            
                                alert(strAlphaNumeric);
                                oi.focus();
                                oi.select();
                                return false;
                                }
                            }
                        }
                        


                        
                    	for(ii=0;ii<minimumAlphaArray.length;ii++)
                        {
                        	if (minimumAlphaArray[ii] == n && v.length != m)
                            {
                            	if (v != "")
                                {                            
                                alert(strMinimumAlpha);
                                oi.focus();
                                oi.select();
                                return false;
                                }
                            }
                        }                                                                   


                break;               
            }

        }

		return true;
    }
    else
    {
    	alert(strUpgrade); 
    }
}';
        
        
        
        $this->jsOnsubmit = 'return checkForm (this,reqArray,numArray,minNumArray,aArray,minAArray,eArray)';
        
        
        
        $this->array = (array) $this->data;
        
        
        $this->obj = $this->data;

    }
    
    
    
    function returnValidation()
    {
        $varArray = array('reqArray','numArray','minNumArray','aArray','minAArray','eArray');
        
        $str = "";
        
        for($ii=0;$ii<count($varArray);$ii++)
        {
            if (count($this->reqArray) > 0)
            {
                $str .= '
var '.$varArray[$ii].' = Array();';
                
                for($i=0;$i<count($this->{$varArray[$ii]});$i++)
                {
                    $str .= '
    '.$varArray[$ii].'['.$i.'] = "'.$this->{$varArray[$ii]}[$i].'";';   
                }
            }
        }
        
        return $str;
    }

    
    function escape($str)
    {
        return mysql_escape_string(stripslashes($str));				
    }
    
    
    
    function returnVar($v)
    {
        if (isset($v))
        {
            if (is_array($v) && count($v) > 0) return $v;
            
            if ($v != "") return trim($v);
        }
        else return '';

    }
    
    function setAction($v)
    {
        $this->action = $v;
        $this->threessDDF($this->db,$this->table,$this->inputSize,$this->action,$this->required);
    }

}
?>
Return current item: 3SS Data Description Form