Scripts

Formulier class

De volgende mogelijkheden heeft de form class: Hieronder staat het voorbeeld zo het script gebruikt zou kunnen worden. Dit is volledig getest.

formulier-class
<?
class FORM
{
	var $xhtml;
	
	function check_xhtml()
	{
		$x = "";

		if($this->xhtml == 1) $x = " /";
		
		return $x;
	}
	
	function textarea($name="",$value="",$cols="",$rows="",$disabled="",$wrap="",$id="",$class="",$style="")
	{
		if($name != "") $name  = " name=\"". $name ."\"";
		if($cols != "") $cols  = " cols=\"". $cols ."\"";
		if($rows != "") $rows  = " rows=\"". $rows ."\"";
		if($wrap != "") $wrap  = " wrap=\"". $wrap ."\"";
		if($id != "")   $id    = " id=\"". $id ."\"";
		if($class != "")$class = " class=\"". $class ."\"";
		if($style != "")$style = " style=\"". $style ."\"";
		
		return "<textarea". $name . $rows . $cols . $wrap . $style . $id . $class . $disabled .">". $value ."</textarea>\n";
	}
	
	function input($type="",$align="",$maxlength="",$alt="",$checked="",$disabled="",$value="",$id="",$class="",$style="")
	{
		if($this->check_xhtml() == " /" && $align != "") $style .= "float:". $align .";"; $align = "";

		if($type == "image") $alt2 = " alt=\"". $alt ."\"";
		elseif(($type == "checkbox" || $type == "radio") && ($checked == "checked"))
		{		     $checked2 = " checked";	}

		if($type != "")      $type      = " type=\"". $type ."\"";
		if($disabled != "")  $disabled  = " disabled";
		if($style != "")     $style     = " style=\"". $style ."\"";
		if($align != "")     $align     = " align=\"". $align ."\"";
		if($maxlength != "") $maxlength = " maxlength=\"". $maxlength ."\"";
		if($value != "")     $value     = " value=\"". $value ."\"";
		if($id != "")        $id        = " id=\"". $id ."\"";
		if($class != "")     $class     = " class=\"". $class ."\"";
		if($style != "")     $style     = " style=\"". $style ."\"";
		
		return "<input". $type  . $align . $maxlength . $style . $alt2 . $value . $checked2 . $class . $id . $disabled . $this->check_xhtml() .">\n";
	}

	function form($action="",$method="",$name="",$target="",$id="",$class="")
	{

		if($action != "") $action = " action=\"". $action ."\"";
		if($method != "") $method = " method=\"". $method ."\"";
		if($name != "")   $name   = " name=\"". $name ."\"";
		if($target != "") $target = " target=\"". $target ."\"";
		if($id != "")     $id     = " id=\"". $id ."\"";
		if($class != "")  $class  = " class=\"". $class ."\"";

		return "<form". $action . $method . $target . $id . $class .">\n";
	
	}

	function formend()
	{
		return "</form>\n";
	}
}
?>

Reacties

0
Nog geen reacties.