I want to get all selected values of bootstrap-multiselect
on button click.
My JSP page code is given below
<script type="text/javascript">
$(document).ready(function() {
$('#ddlPermission').multiselect({
buttonWidth : '100%',
maxHeight : 100,
includeSelectAllOption : true,
dropRight : true
});
});
function myFunction() {
var allVal=$("ddlPermission").val();
alert(allVal);
return false;
}
</script>
<body>
<select id="ddlPermission" multiple="multiple" name="permission_ddl">
<option value="A">A</option>
<option value="B">B</option>
<option value="C">C</option>
<option value="D">D</option>
</select>
<input type="submit" name="btnSubmit" id="btnSubmit" onclick="myFunction()" class="button active" value="Submit">
</body>
I am using Java JSP.
Working fiddle.
You're missing the id sign #
in the following line :
var allVal=$("ddlPermission").val();
Should be :
var allVal=$("#ddlPermission").val();
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With