Re: QuickForm hierselect muiltiple choice problem
| From: | Joshua Eichorn | Date: | Wed, 02 Jun 2004 15:43:53 +0000 |
| Subject: | Re: QuickForm hierselect muiltiple choice problem | ||
| References: | 1 2 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-12836@lists.php.net to get a copy of this message | ||
I have a hierselect more or less working with multiple select. Well actually you can do multiple selects but you the updating of the second selects options is still only populated from the first selelection on the first.
if (!defined('HTML_QUICKFORM_HIERSELECT_EXISTS'))
{
$_js = "function swapOptions(frm, grpName, eleIndex, nbElements, arName)\n"
."{\n"
." var n = \"\";\n"
." var ctl;\n\n"
." for (var i = 0; i < nbElements; i++) {\n"
." ctl = frm.form[grpName+'['+i+'][]'];\n"
." if (i <= eleIndex) {\n"
." n += \"_\"+ctl.value;\n"
." } else {\n"
." ctl.length = 0;\n"
." }\n"
." }\n\n"
." var t = eval(\"typeof(\"+arName + n +\")\");\n"
." if (t != 'undefined') {\n"
." var the_array = eval(arName+n);\n"
." var j = 0;\n"
." n = eleIndex + 1;\n"
." ctl = frm.form[grpName+'['+ n +'][]'];\n"
." for (var i in the_array) {\n"
." opt = new Option(the_array[i], i, false, false);\n"
." ctl.options[j++] = opt;\n"
." }\n"
." }\n"
."}\n";
define('HTML_QUICKFORM_HIERSELECT_EXISTS', true);
}
$gopts = array($theaters,$countries,$regions,$state);
$geo =& $form>addElement('hierselect', 'geo', 'Geographic Area:', array('multiple'=>'multiple','size'=>'5'), " \n");
$geo->setOptions($gopts);
$geo->_js .= $_js;
I'm actually using it in a hierselect 4 levels deep so if anyone has some neat JS for doing multi-swap let me know.
-josh
Alexey Borzov wrote:
Hi! Helder Miguel Rodrigues wrote:Im trying tu use 2 selects, an I wanto to know if it is possible to implement multiple choice in the second select. I have done this: $hsfilerelatorioperm = &$form->addElement('hierselect', 'filerelatorioperm', array('Relatório:'), "size=6 MULTIPLE=true"); $hsfilerelatorioperm->setMainOptions($perms); $hsfilerelatorioperm->setSecOptions(array(array(), array(), array(), array(), $clientsInternet, $clientsInstitucional)); But second select never is populated and it gives me a JavaScript error in IE. If I get off MULTIPLE=true everything works fine! There is any solution to be possible to have multiple selections in the second select?I think you set the 'multiple' attribute for both selects this way. Get the hierselect's elements by using getElements() and update the attributes only of the second one.