Location: PHPKode > scripts > formAt > format/advanceUsage.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>--:.formAt.:--</title>


<style type="text/css">
<!--
a:link {
	text-decoration: none;
}
a:visited {
	text-decoration: none;
}
a:active {
	text-decoration: none;
}
a:hover {
	text-decoration: underline;
}
.style1 {
	font-family: Arial, Helvetica, sans-serif;
	color: #999999;
	font-size: 12px;
}
.fieldStyle {
	font-family: Arial, Helvetica, sans-serif;
	font-size:14px;
	color:#999999;
	border:solid 1px #CCCCCC;
	width:200px
}

.radioCheckStyle {
	font-family: Arial, Helvetica, sans-serif;
	font-size:14px;
	color:#999999;
	width:200px
}
.style2 {
	color: #FFFFFF;
	font-size: 18px;
}
.style4 {font-size: 24px}
.style5 {color: #000066}

-->
</style>
</head>

<body>
<p align="center"><a href="index.html"><img src="logo.gif" width="335" height="67" border="0" /></a></p>
<?
include("config.php");

// INCLUDE CLASS
include("formAt.class.php");
// DECLARE AND INITIALIZE OBJECT

mysql_connect($host,$login,$password);
mysql_select_db($database);

$formAt = new formAt(false); // I won't be connected by the object
$formAt->defaults(false); // don't get the database default values
if(isset($_GET["debug"])){
	$formAt->startDebug();
}
?>
<table width="100%" border="0" cellspacing="2" cellpadding="2">
  <tr>
    <td width="78%" valign="top"><form id="formAt" name="formAt" method="post" action="">
      <table width="529" border="0" align="center" cellpadding="2" cellspacing="2" style="font-family:Arial, Helvetica, sans-serif;font-size:14px;color:#999999">
        <tr>
          <td colspan="2" align="right" valign="top" bgcolor="#B4B4B4"><span class="style2"><a href="basicUsage.php" style="color:#333333">.Basic Usage</a> |<span class="style4"> .Advanced Usage</span> </span></td>
        </tr>
        <tr>
          <td align="right" valign="top">&nbsp;</td>
          <td>
		  <?
		  if(isset($_GET["debug"])){
		  	echo '<a href="'.$_SERVER['PHP_SELF'].'" style="color:red;font-weight:bold">[ STOP DEBUG ]</a>';
		  }
		  else{
			  echo '<a href="'.$_SERVER['PHP_SELF'].'?debug=1" style="color:red;font-weight:bold">[ DEBUG FORM ]</a>';
		   } ?>
		  
		  </td>
        </tr>
        <tr>
          <td width="199" align="right" valign="top">Customer Name </td>
          <td width="316">
		  <?
		// Generate textfield
		echo $formAt->genStrField("car_rental", 			// table
								  "customer_name", 			// column
								  "my Value", 				// default value 
								  "fieldStyle", 			// css style
								  "text",					// type
								  'onChange="alert(this.name+\' field value has changed\')"',	// added javascript code
								  "customer"				// forced field name
								  );
		?>
		  <br />
		  <div align="left">
            <pre style="font-size:9px">//Generate textfield<br />echo $formAt-&gt;genStrField(
 &quot;car_rental&quot;, // table<br /> &quot;customer_name&quot;, // column<br /> &quot;my Value&quot;, // default value <br /> &quot;fieldStyle&quot;, // css style<br /> &quot;text&quot;, // type<br /> 'onChange=&quot;alert(this.name+\' field value has changed\')&quot;',<br /> &quot;customer&quot;// forced field name<br />);</pre>
          </div></td>
        </tr>
        <tr>
          <td align="right" valign="top" bgcolor="#EAEAEA">Rent Mode </td>
          <td bgcolor="#EAEAEA"><?
		// Generate radio set from enum colum 
		echo $formAt->genEnumSetField("car_rental", 		// table
									  "rent_mode", 			// colum
									  "radioCheckStyle",	// css style
									  "select",				// object type
									  array("daily"),		// default value	
									  'onChange="alert(\'Clicked \'+this.value)"'	// added javascript
									  );
		?>          <br />
            <div align="left">
              <pre style="font-size:9px">// Generate radio-set from enum column <br />echo $formAt-&gt;genEnumSetField(<br /> &quot;car_rental&quot;, //table<br /> &quot;rent_mode&quot;,	// column<br /> &quot;radioCheckStyle&quot;, // css style<br /> &quot;select&quot;,	// object type<br /> array(&quot;daily&quot;), // default value	<br /> 'onChange=&quot;alert(\'Clicked \'+this.value)&quot;'<br />);</pre>
            </div></td>
        </tr>
        <tr>
          <td align="right" valign="top">Credit Card </td>
          <td><?
		// Generate checkbos set from set colum 
		echo $formAt->genEnumSetField("car_rental", 		// table
									  "credit_card", 		// colum
									  "radioCheckStyle",	// css style
									  "select",				// object type
									  array("visa","master card"),		// values
									  'style="font-size:18px"',			// added css style code
									  2,					// select size
									  true,					// select-multiple
									  "card"				// forced name
									  );
		?>          <br />
            <div align="left">
              <pre style="font-size:9px">// Generate checkbox-set from set column <br />echo $formAt-&gt;genEnumSetField(<br /> &quot;car_rental&quot;, // table<br /> &quot;credit_card&quot;, // column<br /> &quot;radioCheckStyle&quot;,// css style<br /> &quot;select&quot;, // object type<br /> array(&quot;visa&quot;,&quot;master card&quot;),	// values<br /> 'style=&quot;font-size:18px&quot;', // added css style code<br /> 2, // select size<br /> true, // select-multiple<br /> &quot;card&quot; //forced name<br />);</pre>
            </div></td>
        </tr>
        <tr>
          <td align="right" valign="top" bgcolor="#EAEAEA">Service Description </td>
          <td bgcolor="#EAEAEA"><?
		// Generate textarea
		echo $formAt->genStrField("car_rental", 			// table
								  "service_description", 	// column
								  "I need a ...", 			// default value 
								  "fieldStyle" 				// css style
								  );
		?>
            <br />
            <div align="left">
              <pre style="font-size:9px">// Generate textarea<br />echo $formAt-&gt;genStrField(<br /> &quot;car_rental&quot;, //table<br /> &quot;service_description&quot;, // column<br /> &quot;I need a ...&quot;, // default value <br /> &quot;fieldStyle&quot; // css style<br />);</pre>
            </div></td>
        </tr>
        <tr>
          <td align="right" valign="top">Price</td>
          <td><?
		// Generate textfield
		echo $formAt->genStrField("car_rental", 			// table
								  "price", 					// column
								  "200.00", 				// default value 
								  "fieldStyle" 	,			// css style
								  "text",					// type
								  'style="color:red"',		// added javascript code
								  "price"					// forced field name
								  );
		?>          <br />
            <div align="left">
              <pre style="font-size:9px">// Generate textfield<br />echo $formAt-&gt;genStrField(<br /> &quot;car_rental&quot;, // table<br /> &quot;price&quot;, // column<br /> &quot;200.00&quot;, // default value <br /> &quot;fieldStyle&quot;,	// css style<br /> &quot;text&quot;,	// type<br /> 'style=&quot;color:red&quot;', //added style code<br /> &quot;price&quot; // forced field name<br />);</pre>
            </div></td>
        </tr>
        <tr>
          <td align="right" valign="top" bgcolor="#EAEAEA">Pick-up Time </td>
          <td bgcolor="#EAEAEA"><?
		// Generate textfield 
		echo $formAt->genStrField("car_rental", 			// table
								  "pickup_time", 			// column
								  "", 						// default value 
								  "fieldStyle" 				// css style
								  );
		?>          <br />
            <div align="left">
              <pre style="font-size:9px">// Generate textfield <br />echo $formAt-&gt;genStrField(
 &quot;car_rental&quot;, //table<br /> &quot;pickup_time&quot;, // column<br /> &quot;&quot;, // default value <br /> &quot;fieldStyle&quot; //css style<br />);</pre>
            </div></td>
        </tr>
        <tr>
          <td align="right" valign="top">Drop-off Time </td>
          <td><?
		// Generate textfield 
		echo $formAt->genStrField("car_rental", 			// table
								  "dropoff_time", 			// column
								  "", 						// default value 
								  "fieldStyle" 				// css style
								  );
		?>          <br />
            <div align="left">
              <pre style="font-size:9px">// Generate textfield <br />echo $formAt-&gt;genStrField(
 &quot;car_rental&quot;, // table<br /> &quot;dropoff_time&quot;, // column<br /> &quot;&quot;, // default value <br /> &quot;fieldStyle&quot; // css style<br />);</pre>
            </div></td>
        </tr>
        <tr>
          <td align="right" valign="top" bgcolor="#EAEAEA">Car</td>
          <td bgcolor="#EAEAEA"><?
		// Generate a select object based on a table
		$formAt->setSelectIniLabel("Select a Car"); // Set the first option label for information
		echo $formAt->genCatalogueField("cars",				// table
										"car_id",			// column for value
										"car",				// column for label
										"fieldStyle"	,	// css style
										"checkbox",			// set to checkbox-set
										'WHERE car_id<4',	// sql extra code
										array(1,3),			// selected values	
										'onClick="alert(\'onClick event\')"' // javascript code
										);
		
		
		?>
            <br />
            <div align="left">
              <pre style="font-size:9px">// Generate a select object based on a table<br />$formAt-&gt;setSelectIniLabel(&quot;Select a Car&quot;); // Set the first option<br />echo $formAt-&gt;genCatalogueField(<br /> &quot;cars&quot;, //table<br /> &quot;car_id&quot;,	// column for value<br /> &quot;car&quot;, // column for label<br /> &quot;fieldStyle&quot;,	// css style<br /> &quot;checkbox&quot;, // set to checkbox-set<br /> 'WHERE car_id&lt;4',	// sql extra code<br /> array(1,3), // selected values		'<br /> 'onClick=&quot;alert(\'onClick event\')' // javascript code<br />);</pre>
            </div></td>
        </tr>
        <tr>
          <td colspan="2" align="center" valign="top" bgcolor="#FFFFCC"><span class="style5">STANDALONE FIELDS</span> <br />
            (Not related to database)</td>
          </tr>
        <tr>
          <td align="right" valign="top">Field A </td>
          <td>
		  <?
		  // StandAlone password field
		  echo $formAt->addTHPInput("Field_A", 				// Field Name
		  							"abcd123", 				// Value
									"password", 			// type
									"fieldStyle", 			// css style
									30,						// maxlength
									'onChange="alert(\'The password is: \'+this.value)"'	// javascript
									);
		  ?>		  <br />
		  <div align="left">
            <pre style="font-size:9px">// StandAlone password field<br />echo $formAt-&gt;addTHPInput(
 &quot;Field_A&quot;,	// Field Name<br /> &quot;abcd123&quot;, // Value<br /> &quot;password&quot;, // type<br /> &quot;fieldStyle&quot;, 	// css style<br /> 30, // maxlength<br /> 'onChange=&quot;alert(\'The password is: \'+this.value)&quot;' // javascript<br />);</pre>
          </div></td>
        </tr>
        <tr>
          <td align="right" valign="top" bgcolor="#EAEAEA">Field B </td>
          <td bgcolor="#EAEAEA">
		  <?
		  // Standalone select field
		  
		  // Labels an Values
		  $fieldBData = array(
		  		array("label"=>"b1","value"=>"1"),	
				array("label"=>"b2","value"=>"2"),
				array("label"=>"b3","value"=>"3")	
		 		 );
		  
		 echo $formAt->addSelectList("Field_B", 		// Name
		 							$fieldBData, 		// Data
									"fieldStyle", 		// Css Style
									array(1,3),			// Selected	
									'style="background-color:#ccc"', // Added style 
									3,					// Select size
									true				// select-multiple
									);		  
			?>		  <br />
		  <div align="left">
            <pre style="font-size:9px">// Standalone select field<br />// Labels an Values<br />		  $fieldBData = array(<br />		  		array(&quot;label&quot;=&gt;&quot;b1&quot;,&quot;value&quot;=&gt;&quot;1&quot;),	<br />				array(&quot;label&quot;=&gt;&quot;b2&quot;,&quot;value&quot;=&gt;&quot;2&quot;),<br />				array(&quot;label&quot;=&gt;&quot;b3&quot;,&quot;value&quot;=&gt;&quot;3&quot;)	<br />		 		 );<br />		  <br />echo $formAt-&gt;addSelectList(
 &quot;Field_B&quot;, // Name
 $fieldBData, // Data<br /> &quot;fieldStyle&quot;,	// Css Style<br /> array(1,3), // Selected	<br /> 'style=&quot;background-color:#ccc&quot;', // Added style <br /> 3, // Select size<br /> true // select-multiple<br />);</pre>
          </div></td>
        </tr>
        <tr>
          <td align="right" valign="top">Field C </td>
          <td><?
		  // Standalone checkboox-set 
		  
		  // Labels an Values
		  $fieldCData = array(
		  		array("label"=>"c1","value"=>"1"),	
				array("label"=>"c2","value"=>"2"),
				array("label"=>"c3","value"=>"3")	
		  		);

		  echo $formAt->addCheckBox("Field_C",		// Name
		  							$fieldCData, 	// Data
									"fieldStyle", 	// Css Style
									array(2), 		// Checked
									'onClick="alert(\'onClick Event\')"' // Javascript code
									);
		  
		  ?>		  <br />
		  <div align="left">
            <pre style="font-size:9px">// Standalone checkboox-set 
		  
// Labels an Values
		  $fieldCData = array(
		  		array("label"=>"c1","value"=>"1"),	
				array("label"=>"c2","value"=>"2"),
				array("label"=>"c3","value"=>"3")	
		  		);

echo $formAt->addCheckBox(
 "Field_C",	// Name
 $fieldCData, //Data
 "fieldStyle", // Css Style
 array(2), // Checked
 'onClick="alert(\'onClick Event\')"' // Javascript code
);</pre>
          </div></td>
        </tr>
        <tr>
          <td align="right" valign="top" bgcolor="#EAEAEA">Field D </td>
          <td bgcolor="#EAEAEA">
		  <?
		  // Labels an Values
		  $fieldDData = array(
		  		array("label"=>"d1","value"=>"1"),	
				array("label"=>"d2","value"=>"2"),
				array("label"=>"d3","value"=>"3")	
		  		);
		  
		  echo $formAt->addRadio("Field_C",					// Name
		  						$fieldDData, 				// Data
								"radioCheckStyle", 			// Css Style
								"1", 						// Checked
								'onClick="alert(this.value)"' // Javascript code
								);
		  
		  ?>		  <br />
		  <div align="left">
            <pre style="font-size:9px">// Standalone checkboox-set 
		  
// Labels an Values
		  $fieDdCData = array(
		  		array(&quot;label&quot;=&gt;&quot;c1&quot;,&quot;value&quot;=&gt;&quot;1&quot;),	
				array(&quot;label&quot;=&gt;&quot;c2&quot;,&quot;value&quot;=&gt;&quot;2&quot;),
				array(&quot;label&quot;=&gt;&quot;c3&quot;,&quot;value&quot;=&gt;&quot;3&quot;)	
		  		);

echo $formAt-&gt;addCheckBox(
 &quot;Field_D&quot;,	// Name
 $fieldDData, //Data
 &quot;radioCheckStyle&quot;, // Css Style
 1, // Checked
 'onClick=&quot;alert(this.value)&quot;' // Javascript code
);</pre>
          </div></td>
        </tr>
        <tr>
          <td align="right" valign="top">&nbsp;</td>
          <td><input name="Reset" type="reset" class="fieldStyle" style="width:100px" value="Reset" />
              <label>
              <input name="Submit2" type="submit" class="fieldStyle" style="width:100px" value="Submit" disabled="disabled" />
            </label></td>
        </tr>
      </table>
            </form>
    <p class="style1">&nbsp;</p>
    </td>
  </tr>
</table>
<p>&nbsp;</p>
</body>
</html>
Return current item: formAt