I have the following working code in magento frontend in a form for customer "add a product" functionality that Im developing:
Helper area:
public function getCategoriesDropdown() { $categoriesArray = Mage::getModel('catalog/category') ->getCollection() ->addAttributeToSelect('name') ->addAttributeToSort('path', 'asc') ->addFieldToFilter('is_active', array('eq'=>'1')) ->load() ->toArray(); foreach ($categoriesArray as $categoryId => $category) { if (isset($category['name'])) { $categories[] = array( 'label' => $category['name'], 'level' =>$category['level'], 'value' => $categoryId ); } } return $categories; } PHTML File:
<select id="category-changer" name="category-changer" style="width:150px;"> <option value="">--Select Categories--</option> <?php $_CategoryHelper = Mage::helper("marketplace")->getCategoriesDropdown(); foreach($_CategoryHelper as $value){ foreach($value as $key => $val){ if($key=='label'){ $catNameIs = $val; } if($key=='value'){ $catIdIs = $val; } if($key=='level'){ $catLevelIs = $val; $b =''; for($i=1;$i<$catLevelIs;$i++){ $b = $b."-"; } } } ?> <option value="<?php echo $catIdIs; ?>"><?php echo $b.$catNameIs ?></option> <?php } ?> </select> this code generates a dropdown with categories and subcategories. like this one: 
my main idea is to create n level nested chained dropdowns for subcategories like this example: 
or this layout would be better: 
any guidance or code example to modify the proposed php in order to include an ajax call, or javascript to generate those frontend chained frontends will be appreciated
brgds!