Viewing file: clsForm.php (2.18 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?
class clsForm{
function Start($formName, $action="", $method="post", $type=""){
return "<form name=\"$formName\" action=\"$action\", method=\"$method\">\n";
}
function End(){
return "</form>\n";
}
function Text($name, $value="", $size=40, $maxlength=50, $readonlyYN="") {
$str = "<input type=\"text\" name=\"$name\" value=\"$value\" size=\"$size\" maxlength=\"$maxlength\"";
if($readonlyYN=="Y") $str.= " readonly";
$str.= ">";
return $str;
}
function Hidden($name, $value="") {
return "<input type=\"hidden\" name=\"$name\" value=\"$value\">";
}
function Textarea($name, $value="", $rows="", $cols="", $readonlyYN="") {
$str = "<textarea name=\"$name\" ";
if ($rows=="")
$str.= "rows=\"5\" ";
else
$str.= "rows=\"$rows\" ";
if ($cols=="")
$str.= "cols=\"50\"";
else
$str.= "cols=\"$cols\"";
if($readonlyYN=="Y") $str.= " readonly";
$str.= ">$value</textarea>";
return $str;
}
function Submit($name="sb", $caption="Submit"){
return "<input type=\"submit\" name=\"$name\" value=\"$caption\">";
}
function Reset($name="rs", $caption="เคลียร์"){
return "<input type=\"reset\" name=\"$name\" value=\"$caption\">";
}
function Button($onclickCmd="", $name="bt", $caption="..."){
$str = "<input type=\"button\" name=\"$name\" value=\"$caption\"";
if($onclickCmd<>"") $str.= " onclick=\"$onclickCmd;\"";
$str.= ">";
return $str;
}
function Radio($name, $value, $caption, $checkedYN=""){
$str = "<input type=\"radio\" name=\"$name\" value=\"$value\"";
if($checkedYN=="Y") $str.= " checked";
$str.= ">$caption";
return $str;
}
function Checkbox($name, $value, $caption="", $checkedYN=""){
$str = "<input type=\"checkbox\" name=\"$name\" value=\"$value\"";
if($checkedYN=="Y") $str.= " checked";
$str.= ">$caption";
return $str;
}
function Select($name, $aList, $aValue, $defaultValue="", $text="---เลือกรายการ---"){
$str = "<select name=\"$name\">\n";
$str.= "<option value=\"\">$text\n";
for ($i=0; $i<count($aValue); $i++){
$str.= "<option value=\"$aValue[$i]\"";
$str.= ($aValue[$i]==$defaultValue) ? " Selected" : "" ;
$str.= ">$aList[$i]\n";
}
$str.="</select>";
return $str;
}
} //end class clsFormElementGen
?>
|