responsive nav dropdown 404s to localhost/undefined

I have a script running that converts my nav menu to a dropdown <select> menu for responsive layouts. I have used the script many times on many sites with no issues.

I'm currently building a new site on localhost, and at some unknown point the dropdown menu has stopped working properly. I've only just noticed while doing some testing.

From the home page, if I select any page from the dropdown I get taken to:


From any other page, eg: Services, I get taken to:


The nav still functions perfectly when not a dropdown.

js that creates the dropdown:

$('#nav ul li').each(function(){
		if ($(this).has('ul').length)

	var $menu_select = $("<select />");
	$("<option />", {"selected": "selected", "value": "", "text": "Navigation Menu"}).appendTo($menu_select);

	$("#nav ul li a").each(function(){
		var menu_url = $(this).attr("href");
		var menu_text = $(this).text();
		if ($(this).parents("li").length == 2) { menu_text = '- ' + menu_text; }
		if ($(this).parents("li").length == 3) { menu_text = "-- " + menu_text; }
		if ($(this).parents("li").length > 3) { menu_text = "--- " + menu_text; }
		$("<option />", {"value": menu_url, "text": menu_text}).appendTo($menu_select)

	field_id = "#nav select";
	   value = $(this).attr('value');
	   window.location = value;

HTML that is being output:

<nav id="nav" class="menu-primary-navigation-container">
                <option selected="selected" value="">Navigation Menu</option>
                <option value="http://localhost/">Home</option>
                <option value="http://localhost/services/">Services</option>
                <option value="http://localhost/portfolio/">Portfolio</option>
                <option value="http://localhost/blog/">Blog</option>
                <option value="http://localhost/contact-us/">Contact Us</option>

A few things I have tried so far:

- Turning off all plugins
- Removing any other jQuery added since I knew the menu worked
- Resetting permalinks (currently set to /%category%/%postname%/, but even the default setting gives the same error)

Any help is greatly appreciated, thanks!