Location: PHPKode > scripts > HTML Form Generator > html-form-generator/test.php
<html>
<head>
<style type="text/css">
	/* to list one element under another */
	input, select, label {display: block;)
</style>
</head>
<body>
<?php
require_once 'htmlform.inc.php';
$form = new HTMLForm();
  
/*
 ******************************************** INSTRUCTIONS TO USE ************************************************************

 *	--------------------------------------------------------------------------------------------------------------------------
 *	Program			: HTML Form Field Generator, PHP Class Library
 *	Files			: htmlform.inc.php, htmlform_base.inc.php, htmlform_exc.inc.php
 *	Author			: Lasantha Samarakoon
 *	Date released	: Monday, September 21, 2009
 *	Email			: hide@address.com
 *	Licence			: http://www.gnu.org/licenses/gpl.txt
 *	--------------------------------------------------------------------------------------------------------------------------
 *
 *	This program is a freeware, which falls under GNU Genral Public Licence.
 *	---------------------------------------------------------------------------------------------------------------------------
 *	You can modify this program, without any permission from the author. But be kind enough to send the updated version to the
 *	author through the above mentioned Email address.
 *	---------------------------------------------------------------------------------------------------------------------------
 *	Documentation:
 *			Please refer the test.php file for hints on the usage of this class library.
 *	---------------------------------------------------------------------------------------------------------------------------
 *
 *	************************************* PROUD TO BE A SRI LANKAN...!!! ******************************************************

 
NOTE: [x] indicates that x is optional.

HTMLForm:
	Constructor: ([string name], [string id], [string action], [string method], [string enctype], [string class])
	void addElement(object element, string element_name)
	void removeElement(string element_name)
	string generate();
	
	Properties:
		get_x()
		set_x()
		x = name, id, action, method, enctype, class
------------------------------------------------------------------------------------------------------------------------------
	
TextField, HiddenField, PasswordField:
	Constructor: ([string name], [string id], [string value], [string class], [bool disabled])
	string generate();
	
	Properties:
		get_x()
		set_x()
		x = name, id, value, class, disabled
------------------------------------------------------------------------------------------------------------------------------

Label:
	Constructor: ([string value], [string rel], [string id], [string class])
	string generate()
	Properties:
		get_x()
		set_x()
		x = value, rel, id, class
------------------------------------------------------------------------------------------------------------------------------

SelectBox:
	Constructor: ([string name], [string id], [string class], [bool disabled])
	void addOption(string key, string text, [string value], [bool selected])
	void removeOption(string key)
	string generate()
	
	Properties:
		get_x()
		set_x()
		x = name, id, class, disabled
------------------------------------------------------------------------------------------------------------------------------
	
Textarea:
	Constructor: ([string name], [string id], [string value], [string class], [bool disabled])
	string generate();
	
	Properties:
		get_x()
		set_x()
		x = name, id, value, class, disabled
------------------------------------------------------------------------------------------------------------------------------

CheckBox, Radio:
	Constructor: ([string name], [string id], [bool checked], [string class], [bool disabled])
	string generate();
	
	Properties:
		get_x()
		set_x()
		x = name, id, checked, class, disabled
------------------------------------------------------------------------------------------------------------------------------
		
SubmitButton, ResetButton, GeneralButton:
	Constructor: [string name],[string id], [string value], [string class], [bool disabled]
	string generate()
	
	Properties:
		get_x()
		set_x()
		x = name, id, value, class, disabled
------------------------------------------------------------------------------------------------------------------------------
 */

$form = new HTMLForm(null, null, "server_script.php", "POST", "multipart/form-data");

$form->addElement(new Label("Text field: ", "txt"), "lbl_1");
$form->addElement(new TextField("txt", null, "TextField"), "el_1");

$form->addElement(new Label("Hidden field: ", "hdn"), "lbl_2");
$form->addElement(new TextField("hdn", null, "HiddenField"), "el_2");

$form->addElement(new Label("Password field: ", "pass"), "lbl_3");
$form->addElement(new TextField("pass", null, "PasswordField"), "el_3");
	
$form->addElement(new Label("Select box: ", "sb"), "lbl_4");
$sb = new SelectBox("sb");
	$sb->addOption("1", "Sri Lanka", "lk");
	$sb->addOption("2", "India", "in");
	$sb->addOption("3", "Australia", "au");
	$sb->addOption("4", "United States of America", "us");
	$sb->addOption("5", "Japan", "jp");
$form->addElement($sb, "el_4");

$form->addElement(new Label("Text area: ", "txtarea"), "lbl_5");
$form->addElement(new Textarea("txtarea", null, "Textarea"), "el_5");

$form->addElement(new Label("Check box: ", "chbox"), "lbl_6");
$form->addElement(new CheckBox("chbox", null, true), "el_6");

$form->addElement(new Label("Radio button: ", "rad"), "lbl_7");
$form->addElement(new Radio("rad"), "el_7");

$form->addElement(new SubmitButton("btnsub", null, "Submit"), "el_8");
$form->addElement(new ResetButton("btnrst", null, "Reset"), "el_9");
$form->addElement(new GeneralButton("btngen", null, "General"), "el_10");

echo $form->generate();
 
?>
</body>
</html>
Return current item: HTML Form Generator