Dynamic Drop Down Menu
-
Hello,
I am using the below referenced code in order to do a “Drop Down Menu” on my website. I use a plugin called Event Espresso. Right now what it does is returns all my events by title, but I want to change it so that it references just the name of the city the event is in. Can someone give me a hint on where I would want to change what is displayed to the end user on the </select> portion that makes the drop down box?
<h2>Search Classes by Location</h2>
[insert_php]#wp_dropdown_pages(“child_of=510”);[/insert_php]<select id=”page_id” name=”page_id”>
[insert_php]
$pages = get_pages(“child_of=510”);
#$pages = get_pages();
echo(“<option value=”>Please Select…</option>”);
foreach ( $pages as $page ) {
$title = $page->post_title;
if (strpos($title, “Black Belt Training”) != False) {
$option = ‘<option value=”‘ . $page->ID . ‘”>’;#$loc = strpos($title,”-“);
#$title = substr($title,0,$loc);
#$title = trim($title);
#$title = str_replace(” “, “, “, $title);$option .= $title;
$option .= ‘</option>’;
echo $option;
}
}
[/insert_php]
</select><script type=”text/javascript”>
var dropdown = document.getElementById(“page_id”);
function onCatChange()
{
if ( dropdown.options[dropdown.selectedIndex].value > 0 )
{
location.href = “[insert_php]echo get_option(‘home’);[/insert_php]/?page_id=”+dropdown.options[dropdown.selectedIndex].value;
}
}
dropdown.onchange = onCatChange;
</script>
- The topic ‘Dynamic Drop Down Menu’ is closed to new replies.