<?php
class CheckBox extends Form_Element
{
// description: Show a checkbox filled with database-value 0 or 1.
// version: 1.1
// history: 26-2-2002 release first version
// 12-3-2002 start with grey_out (1.1)
var $Connection = 0;
var $SQL_Update_Query;
var $SQL_Show_Query;
var $Grey_Out = 0;
function CheckBox($Name)
{
$this->Set_Element_Name($Name);
}
function Show()
{
if ($this->Connection != 0)
{
// get rescent field-value from database
$result = odbc_exec($this->Connection,$this->SQL_Show_Query);
if (odbc_fetch_row($result))
{
$Show_Value = odbc_result($result,1);
if ($Show_Value != 0) $Value_String = "checked";
else $Value_String = "unchecked";
}
else print"odbc failed ".$this->SQL_Show_Query;
// update record
if (!empty($this->SQL_Update_Query))
{
odbc_exec($this->Connection,$this->SQL_Update_Query);
}
}
else
{
// support for manual (no database) use
// I will add this part in the future
}
// Set grey_out to the box (disable changing)
if ($this->Grey_Out != 0) $Grey_String = " disabled";
else $Grey_String = "";
// show checkbox
print"<input type=checkbox name='".$this->Element_Name."' ".$Value_String.$Grey_String.">\n";
}
}
?>