<?php
 
 
 
class TextArea extends Form_Element
 
{
 
    // description: Use with class_forms.php.
 
    //              Show a textarea with text from database you can change.
 
    // version:     1.2
 
    // history:     15-02-2002 Release version 1.0
 
    //              19-08-2002 Set counter.
 
    //              14-09-2002 No query, no text. JSCounterExpansion added.
 
 
    var $Connection;
 
    var $NrRows = 10;
 
    var $NrCols = 40;
 
    var $SQL_Update_Query;
 
    var $SQL_Show_Query;
 
    var $Type = "text";
 
    var    $Counter_Used = 0;
 
    var $Counter_Disabled = 1;
 
    var $CounterValue = 125;
 
    var $JSCounterExpansion = "";
 
 
    function TextArea($Name)
 
    {
 
        $this->Set_Element_Name($Name);
 
    }
 
 
    function Show_Counter_Function()
 
    {
 
        print"<script language='javascript'>\n";
 
        print"function TextCounter(field, countfield, maxlimit){\n";
 
        print"if (field.value.length > maxlimit)\n";
 
        print"field.value = field.value.substring(0, maxlimit);\n";
 
        print"else \n";
 
        print"countfield.value = maxlimit - field.value.length;\n";
 
        print $this->JSCounterExpansion;
 
        print"}\n";
 
        print"</script>\n";
 
        $this->Counter_Used = 1;
 
    }
 
 
    function Show_Textcolor_Function()
 
    {
 
        // still in test...
 
        print"<script language='javascript'>\n";
 
        print"function TextColor(){\n";
 
        print"document.c.taHoi.style.color = 'red';\n";
 
        print"}\n";
 
        print"</script>\n";
 
        $this->Counter_Used = 1;
 
    }
 
 
    function Show()
 
    {
 
        if ($this->Connection != 0)
 
        {    
 
            // update record
 
            if (!empty($this->SQL_Update_Query))
 
            {
 
                odbc_exec($this->Connection,$this->SQL_Update_Query);
 
            }
 
 
            // rescent value from database
 
            if (!empty($this->SQL_Show_Query))
 
            {
 
                $result = odbc_exec($this->Connection,$this->SQL_Show_Query);
 
                if (odbc_fetch_row($result))
 
                {
 
                    $Show_Value = odbc_result($result,1);
 
                }                
 
            }
 
            else
 
            {
 
                $Show_Value = "";
 
            }
 
        }
 
        else
 
        {
 
            print "textarea zonder DB-aansturing hier<br>";
 
        }
 
        
 
        // show textarea
 
        print"<textarea type=text name='".$this->Element_Name."' rows=".$this->NrRows." cols=".$this->NrCols;
 
 
        // show counter
 
        if ($this->Counter_Used == 1) print" wrap=physical onKeyDown=\"TextCounter(this.form.".$this->Element_Name.",this.form.remLen,".$this->CounterValue.");\" onKeyUp=\"TextCounter(this.form.".$this->Element_Name.",this.form.remLen,".$this->CounterValue.");\"";
 
        print ">";
 
        print $Show_Value;    
 
        print"</textarea>\n";
 
    }
 
 
    function Show_Counter($Size = 3)
 
    {
 
        if ($this->Counter_Disabled != 0) $Disabled = "DISABLED";
 
            else $Disabled = "";
 
        print"<input readonly ".$Disabled." type=text name=remLen size=".$Size." maxlength=".$Size." value=\"".$this->CounterValue."\">";
 
    }
 
 
    function Show_Textcolor_Button()
 
    {
 
        // still in test...
 
        print"<input type=button value='textcolor' onClick='TextColor()'>";
 
    }
 
}
 
 
?>
 
 
 |