user5005768Himadree
user5005768Himadree

Reputation: 1427

JQuery: How to Choose values from multiselect

I want to make a month list drop down menu which will choose values instead of option text.I used JQuery Multiselect.js and this is the code: Notice: CDN Links Don't work here.But i've lib file that works fine.

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Multi-select Dropdown List with Checkbox by CodexWorld</title>
<link href="https://cdn.jsdelivr.net/jquery.multiselect/1.13/jquery.multiselect.css" rel="stylesheet" type="text/css">
<style>
body { font-family:'Open Sans' Arial, Helvetica, sans-serif}
ul,li { margin:0; padding:0; list-style:none;}
.label { color:#000; font-size:16px;}
</style>
</head>
<body>
    
<h2>jQuery MultiSelect Basic Uses</h2>
<select name="langOpt[]" multiple id="langOpt" >
 <option value="All">All</option>
 <option value="Jan">January</option>
 <option value="Feb">February</option>
 <option value="Mar">March</option>
 <option value="Apr">April</option>
 <option value="May">May</option>
 <option value="Jun">June</option>
 <option value="Jul">July</option>
 <option value="Aug">August</option>
 <option value="Sep">September</option>
 <option value="Oct">October</option>
 <option value="Nov">November</option>
 <option value="Dec">December</option>
</select>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/jquery.multiselect/1.13/jquery.multiselect.js"></script>
<script>
$('#langOpt').multiselect({	
    placeholder: 'Select Months'
});

</script>



</body>
</html>
The given code is working fine for option text.However if an user choose: November and December then i want to output option values: Nov, Dec.

Please Help Thanks.

Upvotes: 0

Views: 2922

Answers (1)

trungvose
trungvose

Reputation: 20034

It's better to have drop-down checkbox instead of multiple select.

You check the question below

Bootstrap dropdown checkbox select

Also try that one and let me know

http://www.jqueryscript.net/demo/jQuery-Multiple-Select-Plugin-For-Bootstrap-Bootstrap-Multiselect/

Cheer

Upvotes: 1

Related Questions