PEAR logo

HTML_QuickForm_advmultiselect : The Definitive Guide



Name

HTML_QuickForm_advmultiselect::setJsElement - Sets JavaScript function name parts. Maybe usefull to avoid conflict names

Synopsis

      require_once 'HTML/QuickForm/advmultiselect.php';
     
void HTML_QuickForm_advmultiselect::setJsElement( $pref = NULL,
$post = 'moveSelections');
string $pref = NULL;
string $post = 'moveSelections';

Description

If you want to change the name of the JavaScript functions that manage items from one list to the other one, for any reason (follow project coding, avoid conflict name, ...), you can do it. The main default function name is moveSelections, without prefix.

Parameter

string $pref

(optional) Prefix name

string $post

(optional) Postfix name

Throws

throws no exceptions thrown

Note

since 0.4.0

This function can not be called statically.

See

HTML_QuickForm_advmultiselect::getElementJs

Example

While default JavaScript function names are : moveSelections, updateHidden, moveUp, moveDown, moveSwap , in this example, the prefix is set to 'fruit' and the main function is called 'Selection', and others ones are: fruitupdateHidden, fruitmoveUp, fruitmoveDown, fruitmoveSwap

  1. <?php
  2. require_once 'HTML/QuickForm.php';
  3. require_once 'HTML/QuickForm/advmultiselect.php';
  4.  
  5. $form = new HTML_QuickForm('ams');
  6. $form->removeAttribute('name');        // XHTML compliance
  7.  
  8. $fruit_array = array(
  9.     'apple'     =>  'Apple',
  10.     'orange'    =>  'Orange',
  11.     'pear'      =>  'Pear',
  12.     'banana'    =>  'Banana',
  13.     'cherry'    =>  'Cherry',
  14.     'kiwi'      =>  'Kiwi',
  15.     'lemon'     =>  'Lemon',
  16.     'lime'      =>  'Lime',
  17.     'tangerine' =>  'Tangerine',
  18. );
  19.  
  20. $ams =& $form->addElement('advmultiselect', 'fruit', null, $fruit_array);
  21. $ams->setLabel(array('Fruit:', 'Available', 'Selected'));
  22. $ams->setJsElement('fruit', 'Selection');
  23.  
  24. // ....
  25. ?>
HTML_QuickForm_advmultiselect : The Definitive Guide v 1.4.0 : 9 Juin 2007