I'm relatively new to D3 and have been having a few issues getting started. I've created a dropdown menu using the code below
var signal = d3.select('#signal_container');
var signalName = ["Please Select", "Temperature", "Pressure", "Load"];
var signalSelect = signal
.append('select')
.attr('class', 'select')
.attr('multiple', '');
var signalOptions = signalSelect
.selectAll('option')
.data(signalName).enter()
.append('option')
.text(function (d) { return d; });
I was wondering if there was a way to limit the number of options that the user can select in the multiple select dropdown menu? Say I want to set the limit at 2 and they've selected 'Temperature' and 'Load', if they were to try and select 'Pressure' it wouldn't be possible as the limit for selected options is set at 2.
Also, how would I be able to get the values of the selected options? I'm currently using
d3.select('#signal_container').select('select').property('value');
But obviously that is only getting the value of the first select options.
Thanks in advance for your help