javascript - Double Drop-Down Menu with HTML and JS?

I needed the drop-down menu options to run a certain function, and someone helped me with this code below.

Is there anyway I can implement the double drop down to the below JSFiddle?

http://jsfiddle.net/v6wRY/4/

HTML:

<select>

<option value="func1">Chocolate</option>

<option value="func2">Candy</option>

<option value="func3">Taffy</option>

</select>

<div></div>

And the JS:

var functions = {

func1: function(){console.log("func1 called")},

func2: function(){console.log("func2 called")},

func3: function(){console.log("func3 called")},

}

$( "select" )

.change(function () {

var selected = $( "select option:selected" );

functions[selected.val()]();

})

.change();

网友答案:

In my experience, it is either impossible or terribly difficult to make a double drop down by way of a select with options. I recommend using an unordered list format instead, depending on what exactly you need it for you can format it in such a way that still works with what you're doing.