onclick attribute in tag <a> doesnt work correctly

~LEO~

New Member
I have a menu which get its items from database.I want to get the menu id of clicked menu in following for each:\[code\]public function gen_menu($menuItems, $pId = 0){ $menu = ''; $ulStart = 0; $base_url = base_url(); $uri = $this->uri->segment(1); foreach($menuItems as $row) { if($row->parent_id==$pId) { if($ulStart==0) { $menu .= "<UL>"; $ulStart++; } $url = $row->item_url; stripos($url,$base_url)===0 || $url==""?$base_url = base_url():$base_url=""; { if($row->external==1){ $menu .= '<LI><a href="'.$row->custom_url.'" title="'.$row->alt_title.'">'.$row->item_title.'</a>'.$this->gen_menu($menuItems, $row->item_id).'</LI>'; } else{ $class = ($uri==$row->custom_url)?"class='selected'":""; $menu .= '<LI '.$class.'><a href="'.site_url($row->custom_url).'/'.$row->item_id.'" title="'.$row->alt_title.'">'.$row->item_title.'</a>'.$this->gen_menu($menuItems, $row->item_id).'</LI>'; } } } } if($ulStart!=0) { $menu .= "</UL>"; } return $menu;}`\[/code\]When I am using onclick in it returns the last id of table always.
 
Back
Top