QF, Html_Ajax, Smarty

From: Date: Sun, 06 Aug 2006 20:12:22 +0000
Subject: QF, Html_Ajax, Smarty
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-24838@lists.php.net to get a copy of this message
Hi, I'd like to create a page with QuickForm, Ajax and Smarty. I've 3 select list and if I select an element from one of them, I'd like to run a query. Here's my code: rights.php (it's the main file with ajax, quickform and dynamic smarty): if ($_REQUEST['act'] == "ajax") { require_once 'HTML/AJAX/Server.php'; $server = new HTML_AJAX_Server(); $server->handleRequest(); } require_once 'HTML/QuickForm.php'; require_once 'HTML/QuickForm/Renderer/ArraySmarty.php'; $form =& new HTML_QuickForm('frm_rights', 'post', 'admin.php?mid='.$menu_id); . . . (here's 3 select element) $select =& $form->addElement('select', 'modules', $strAdminRightsModules, $modules, 'onChange="javascript:tyu('.$menu_id.', 4)"'); ajax.php (here's the query what I want to run): if ($_REQUEST['act'] == "rights" && isset($_REQUEST['id']) && is_numeric($_REQUEST['id'])) { $id = intval($_REQUEST['id']); $query = "
       SELECT f.function_id AS fid, f.function_name AS fname, f.function_alias AS falias
       FROM iShark_Functions f
       WHERE module_id = '$id'
       ORDER BY f.function_id
"; $result = $mdb2->query($query); $i = 0; while ($row = $result->fetchRow()) {
       //$functionchk[] = &HTML_QuickForm::createElement('checkbox', $row['fid'], null, $row['fname']);
       $functionchk[$i]['fid']    = $row['fid'];
       $functionchk[$i]['fname']  = $row['fname'];
       $functionchk[$i]['falias'] = $row['falias'];
       $i++;
} //$form->addGroup($functionchk, 'functions', $strAdminRightsFunctions, array('&nbsp;', '<br />')); //$tpl->assign('functionchk', $functionchk); print_r($functionchk); } rights.tpl (here's the template): <script type="text/javascript" src="admin.php?p=rigths&amp;act=ajax&amp;client=all"></script> <script type="text/javascript"> function tyu(menu_id, id) {literal}{ HTML_AJAX.replace('target','ajax.php?act=rights&id='+id); }{/literal} </script> <td id="target">
       {foreach from=$functionchk item=data}
           {$data.fid} {$data.fname}
       {/foreach}
</td> But it's not working for me correctly. I see the correct array with print_r but I can't add to the template or QuicForm. How can I use Ajax with Smarty and QuickForm (and MDB2)? Thanks a lot ZoTyA

« previous php.pear.general (#24838) next »