Source for file qfams_multiple_2.php
Documentation is available at qfams_multiple_2.php
* Two advMultiSelect HTML_QuickForm elements with all properties
* that can be display in one or two select box mode.
* This example demonstrate the new feature of version 1.3.0 : Live Counter
* @version $Id: qfams_multiple_2.php,v 1.2 2008/04/26 13:25:14 farell Exp $
* @author Laurent Laville <pear@laurent-laville.org>
* @package HTML_QuickForm_advmultiselect
* @example examples/qfams_multiple_2.php
* qfams_multiple_2 source code
* @link http://www.laurent-laville.org/img/qfams/screenshot/multiple2.png
* screenshot (Image PNG, 595x511 pixels) 11.9 Kb
require_once 'HTML/QuickForm.php';
require_once 'HTML/QuickForm/advmultiselect.php';
$form = new HTML_QuickForm ('amsMultiple2');
$form->removeAttribute ('name'); // XHTML compliance
'tangerine' => 'Tangerine',
// template for a single checkboxes multi-select element shape with live counter
<!-- BEGIN label_3 --><tr><th>{label_3}(<span id="{selected_count_id}">{selected_count}</span>)</th><th> </th></tr><!-- END label_3 -->
<td>{all}<br />{none}<br />{toggle}</td>
// template for a dual multi-select element shape with live counter
<!-- BEGIN label_2 --><tr><th>{label_2}(<span id="{unselected_count_id}">{unselected_count}</span>)</th><!-- END label_2 -->
<!-- BEGIN label_3 --><th> </th><th>{label_3}(<span id="{selected_count_id}">{selected_count}</span>)</th></tr><!-- END label_3 -->
{add}<br />{remove}<br /><br />{all}<br />{none}<br />{toggle}<br /><br />{moveup}<br />{movedown}<br />
$form->addElement ('header', null , 'Advanced Multiple Select: Live Counter - pool1 style ');
$ams1 = & $form->addElement ('advmultiselect', 'cars', null , $car_array,
array ('size' => 10 , 'class' => 'pool1', 'style' => 'width:200px;')
$ams1->setLabel (array ('Cars:', 'Available', 'Selected'));
$ams1->setButtonAttributes ('add', array ('name' => 'add1', 'class' => 'inputCommand'));
$ams1->setButtonAttributes ('remove', array ('name' => 'remove1', 'class' => 'inputCommand'));
$ams1->setButtonAttributes ('all', array ('name' => 'all1', 'class' => 'inputCommand'));
$ams1->setButtonAttributes ('none', array ('name' => 'none1', 'class' => 'inputCommand'));
$ams1->setButtonAttributes ('toggle', array ('name' => 'toggle1', 'class' => 'inputCommand'));
$ams1->setButtonAttributes ('moveup', array ('name' => 'moveup1', 'class' => 'inputCommand'));
$ams1->setButtonAttributes ('movedown', array ('name' => 'movedown1', 'class' => 'inputCommand'));
if (isset ($_POST['multiselect1'])) {
$ams1->setElementTemplate ($template2);
$ams1->setElementTemplate ($template1);
if (isset ($_POST['cars'])) {
$defaults = array ('cars' => $_POST['cars']);
$form->addElement ('header', null , 'Advanced Multiple Select: Live Counter - pool2 style ');
$ams2 = & $form->addElement ('advmultiselect', 'fruit', null , $fruit_array,
array ('size' => 5 , 'class' => 'pool2', 'style' => 'width:300px;')
$ams2->setLabel (array ('Fruit:', 'Available', 'Selected'));
$ams2->setButtonAttributes ('add', array ('name' => 'add2', 'class' => 'inputCommand'));
$ams2->setButtonAttributes ('remove', array ('name' => 'remove2', 'class' => 'inputCommand'));
$ams2->setButtonAttributes ('all', array ('name' => 'all2', 'class' => 'inputCommand'));
$ams2->setButtonAttributes ('none', array ('name' => 'none2', 'class' => 'inputCommand'));
$ams2->setButtonAttributes ('toggle', array ('name' => 'toggle2', 'class' => 'inputCommand'));
$ams2->setButtonAttributes ('moveup', array ('name' => 'moveup2', 'class' => 'inputCommand'));
$ams2->setButtonAttributes ('movedown', array ('name' => 'movedown2', 'class' => 'inputCommand'));
if (isset ($_POST['multiselect2'])) {
$ams2->setElementTemplate ($template2);
$ams2->setElementTemplate ($template1);
if (isset ($_POST['fruit'])) {
$defaults = array_merge($defaults, array ('fruit' => $_POST['fruit']));
$buttons[] = & $form->createElement ('submit', null , 'Submit');
$buttons[] = & $form->createElement ('reset', null , 'Reset');
$buttons[] = & $form->createElement ('checkbox', 'multiselect1', null ,
'cars list dual select');
$buttons[] = & $form->createElement ('checkbox', 'multiselect2', null ,
'fruit list dual select');
$form->addGroup ($buttons, null , ' ');
if (count($defaults) > 0 ) {
$form->setDefaults ($defaults);
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3c.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>HTML_QuickForm::advMultiSelect multiple example 2</title>
font-family: Verdana, Arial, helvetica;
table.pool1, table.pool2 {
background-color: #339900;
table.pool1 th, table.pool2 th {
table.pool1 td, table.pool2 td {
table.pool1 select, table.pool2 select {
background-color: #006600;
background-color: #d0d0d0;
if (!isset ($_POST['multiselect1'])) {
echo $ams1->getElementCss ();
if (!isset ($_POST['multiselect2'])) {
echo $ams2->getElementCss ();
<?php echo $ams1->getElementJs (false ); ?>
<script type="text/javascript">
window.qfamsName = new Array();
window.qfamsName[0] = 'cars';
window.qfamsName[1] = 'fruit';
window.addEventListener('load', qfamsInit, false);
$clean = $form->getSubmitValues ();
Documentation generated on Sat, 26 Apr 2008 14:30:13 -0400 by phpDocumentor 1.4.0. PEAR Logo Copyright © PHP Group 2004.
|