NeedZoom Posted January 30, 2014 Share Posted January 30, 2014 (edited) I have two combobox : "<select> </select>" from database. one combobox depends on another combobox.I have a problem with the connection between the two. The first combobx : in tpl file : <select onchange=" " name="id"> <option value="Select">Select</option> {foreach from=$categories item=categorie} <option value="$id = {$categorie.id_category}" {if $smarty.id}selected = "selected"{/if}>{$categorie.id_category}</option> {/foreach} </select> in Controller.php public function initContent() {parent::initContent(); $categories = Db::getInstance()->ExecuteS(' //my sql '); $this->context->smarty->assign('categories',$categories); //$this->context->smarty->assign('souscategories',$souscategories); $this->setTemplate(_PS_THEME_DIR_.'mytpl.tpl'); } The seconde combobx: When the customer choose the category, retrieve the id of this class and run the seconde query $id=Tools::getValue('id'); $souscategories = Db::getInstance()->ExecuteS(' SELECT * FROM table where n = '.$id.''); Thanks to give some help , idea solve it Edited January 30, 2014 by NeedZoom (see edit history) Link to comment Share on other sites More sharing options...
NeedZoom Posted January 31, 2014 Author Share Posted January 31, 2014 Now the second combobox work but i should clik the botton in my file TPL i use : {if $smarty.post.id}selected = "selected"{/if}> in the fil controller.php: if($id=Tools::getValue('id')){ $souscategories = Db::getInstance()->ExecuteS( SELECT * FROM table where champs = '.$id.' and '); $this->context->smarty->assign('souscategories',$souscategories); } I don't any idea to slove this problem , PLZ help me Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now