简体   繁体   中英

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.

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

sorry for come very late, you can use $('#your_select').multiSelect('select', String or Array);

for select item(s) and use

$('#your_select').multiSelect('deselect', String or Array);

for diselecting item(s). See the documentation in: http://loudev.com

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM