Hi,
Please help me to create chainedselect in my modules...
This is a example of hierselect in the pear package.
$select1 = $select2 = $select3 = array();
$select1[0] = 'Pop';
$select1[1] = 'Classical';
$select1[2] = 'Funeral doom';
// second select
$select2[0][0] = '--- Artist ---';
$select2[0][1] = 'Red Hot Chil Peppers';
$select2[0][2] = 'The Pixies';
$select2[1][0] = '--- Artist ---';
$select2[1][1] = 'Wagner';
$select2[1][2] = 'Strauss';
$select2[2][0] = '--- Artist ---';
$select2[2][1] = 'Pantheist';
$select2[2][2] = 'Skepticism';
// Create a third select with prices for the cds
$select3[0][0][0] = '--- Choose the artist ---';
$select3[0][1][0] = '15.00$';
$select3[0][2][1] = '17.00$';
$select3[1][0][0] = '--- Choose the artist ---';
$select3[1][1][0] = '15.00$';
$select3[1][2][1] = '17.00$';
$select3[2][0][0] = '--- Choose the artist ---';
$select3[2][1][0] = '15.00$';
$select3[2][2][1] = '17.00$';
$sel =& $form->addElement('hierselect', 'cds', 'Choose CD:');
$sel->setOptions(array($select1, $select2, $select3));
I want to develop above example using chainedselect.
I tried following way but it is not working properly.. sel2 & sel3 drop down are showing id of selected value from sel1 drop down
$form->addElement('select','sel1','sel1', $select1,array('id'=>'sel1'));
$form->addElement('select','sel2','sel2',array(),array('id'=>'sel2'));
$form->addElement('select','sel3','sel3', array(),array('id'=>'sel3'));
Utils_ChainedSelectCommon::create('sel2',array('sel1'),'modules/CRM/mymodules/update_sel.php',null,$form->exportValue('sel2'));
Utils_ChainedSelectCommon::create('sel3',array('sel1','sel2'),'modules/CRM/mymodules/update_sel.php',null,$form->exportValue('sel3'));
update_sel.php file code :
defined("_VALID_ACCESS") || die('Direct access forbidden');
$ret = '';
$values = $_POST['values'];
foreach($values as $v) {
$ret .= $v;
}
print(json_encode(array('a'=>$ret,'b'=>$ret)));
Please help me as fast as possible & provide the chainedselect documents.
Thanks,
Kishor