Login   Register  
PHP Classes
elePHPant
Icontem

File: example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Julien PACHET  >  Form Classic  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Exmaple of use of form_classic class
Class: Form Classic
Generate the HTML for forms with common inputs
Author: By
Last change:
Date: 10 years ago
Size: 2,615 bytes
 

Contents

Class file image Download
<?
  
require_once("class_form_classic.inc.php");
  
$self="example.php";
  if (isset(
$HTTP_GET_VARS['radio_value']))
    
$radio_value=$HTTP_GET_VARS['radio_value'];
  else
    
$radio_value="B";
  if (isset(
$HTTP_GET_VARS['select']))
    
$select=$HTTP_GET_VARS['select']*1// to set numeric
  
if (($select==-1)||($select==""))
    
$select="Roma"// with this default value, the select control will set ascending order the nearset value

  
$check1=$HTTP_GET_VARS['check1'];
  
$check2=$HTTP_GET_VARS['check2'];
  
$check3=$HTTP_GET_VARS['check3'];
  
  if (isset(
$HTTP_GET_VARS['enable']))
    
$enable=$HTTP_GET_VARS['enable'];
  else
    
$enable=false;
?>
<html>
<head>
</head>
<body>
<?
  
echo $select;
  echo 
"<a href=$self>rafraichir</a>\n";
  
$f=new form_classic($self); // autogenerate form name mode
  
echo $f->begin();
  echo 
"<fieldset>\n";
  echo 
"<legend>",$f->checkbox(1,"enable",$enable,false,$f->name.".submit();")," Enable form</legend>\n";
  echo 
"<table>\n";
  
  
// example of a text field
  
echo "<tr><td width=150>text:</td><td>",$f->text(1,"text",$text,!$enable,10,10),"</td></tr>\n";
  
  
// example of a password field
  
echo "<tr><td>password:</td><td>",$f->password(1,"password",!$enable,10,10),"</td></tr>\n";
  
  
// example of an hidden field
  
echo "<tr><td>hidden:</td><td>",$f->hidden(1,"hidden",$hidden),"</td></tr>\n";
  
  
// example of a radio set of fields
  
$radio_values=array("A","B","C");
  echo 
"<tr><td>radio buttons:</td><td>";
  echo 
"choice A:",$f->radio(1,"radio_value",$radio_values,0,$radio_value,!$enable,""),"&nbsp;";
  echo 
"choice B:",$f->radio(1,"radio_value",$radio_values,1,$radio_value,!$enable,""),"&nbsp;";
  echo 
"choice C:",$f->radio(1,"radio_value",$radio_values,2,$radio_value,!$enable,""),"&nbsp;";
  echo 
"</td></tr>\n";
  
  
// example of a checked boxes fields
  
echo "<tr><td>check boxes:</td><td>";
  echo 
$f->checkbox(1,"check1",($check1==1),!$enable),"check 1<br>\n";
  echo 
$f->checkbox(1,"check2",($check2==1),!$enable),"check 2<br>\n";
  echo 
$f->checkbox(1,"check3",($check3==1),!$enable),"check 3<br>\n";
  echo 
"</td></tr>\n";
  
  
// example of a drop down field
  
echo "<tr><td>Drop down select:</td><td>\n";
  echo 
$f->select_from_arrays(1,"select",array(0,1,2,3,4,5,6),array("London","New York","Madrid","Berlin","Rome","Pekin","Le Caire"),$select,"",!$enable);
  echo 
"</td></tr>\n";
  
  
// and... example of the submit field
  
echo "<tr><td>submit:</td><td>",$f->submit(1,"Valid",!$enable),"</td></tr>\n";
  echo 
"</fieldset>\n";
  echo 
$f->end();
?>
</body>
</html>