I am trying to use split on a multiple selection dropdown menu and it is returning an error of: “Uncaught TypeError: Object f-all has no method ‘split'”. Is it not possible to use split on a multi select?
Here is the dropdown (simplified):
<select data-placeholder="Select" placeholder="Select" name="id[]" id="id_menu" multiple>
<option value=""></option>
<option value="e-all">E All</option>
<option value="f-all">F All</option>
</select>
And here is the split function:
$('#id_menu').change(function(){
var id_menu = $(this).val();
var type = id_menu.split('-');
// do stuff with split id
});
Tried with an each an still same error message
$('#id_menu').change(function(){
$('#id_menu').each(function() {
var type = $(this).val().split(',');
});
});
Thanks in advance.
1 Answer