Old Question but still first item regarding dropdown menus and processwire on google. So here is my solution
<div class="collapse navbar-collapse navbar-right navbar-main-collapse">
<!-- top navigation -->
<ul class='nav navbar-nav'>
<?php
// top navigation consists of homepage and its visible children
$homepage = $pages->get('/');
$children = $homepage->children();
// make 'home' the first item in the navigation
$children->prepend($homepage);
// render an <li> for each top navigation item
foreach($children as $child) {
if($child->id == $page->rootParent->id) {
// this $child page is currently being viewed (or one of it's children/descendents)
// so we highlight it as the current page in the navigation
echo "<li class='current active'><a href='$child->url'>$child->navlinkname</a></li>"; //<!-- Bootstrap active Class-->
} else {
if($child->hasChildren() && $child->id != 1) {
$navigation = "<li class='dropdown'><a class='dropdown-toggle' data-toggle='dropdown' href='$child->url'>$child->title</a>";
$navigation .= "<ul class='dropdown-menu sub_menu'>";
foreach ($child->children as $item) {
$navigation .= "<li><a href='$item->url'>$item->navlinkname</a></li>";
}
$navigation .= "</ul>";
$navigation .= "</li>";
echo $navigation;
}else{
$menu = "<li class='item'><a href='$child->url'>$child->title</a></li>";
echo $menu;
}
}
}
?>
</div>