I am having trouble finding selected options when using a <select multiple>
dropdown.
SO has a few discussions for finding the user selected option (not plural) from a dropdown menu: link1, link2, link3.
The major question is in the code below.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="http://d3js.org/d3.v3.min.js"></script>
<style>
</style>
</head>
<body>
<div>
<select multiple id="menu">
</select>
</div>
<script>
var some_array=["Bob","Tom"]
var menu = d3.selectAll("#menu")
menu.selectAll("option")
.data(some_array)
.enter()
.append("option")
.attr("value", function(d) { return d; })
.text(function(d) { return d; });
menu.on("change",function(event) {
//HOW CAN I GET THE OPTION(S) THAT THE USER HAS SELECTED?
//BEST GUESS:
selections=d3.select(this).selectAll("options:checked")
console.log(selections)
})
</script>
</body>
</html>
The problem with this script is that I'm not seeing the values "Bob" and "Tom" in the array displayed in the console.