javascript - (Multiple Select) Arrange options depends on user selection -
does know how in jquery , selected options order depends on user selection?
<select class="form-control" name="cols[]" multiple="multiple" id="cols[]" required="required"> <option value="latest_upd">latest update</option> <option value="status">status</option> <option value="spin">spin</option> <option value="file_location">file location</option> <option value="upl_webgis">uploaded webgis</option> <option value="rem_upl">remarks on upload</option> </select>
try : using php , jquery both
<html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> </head> <body> <?php echo "<pre>",print_r($_post,1),"</pre>"; ?> <form action="" method="post"> <select class="form-control" name="cols[]" multiple="multiple" id="cols[]" required="required"> <option value="latest_upd">latest update</option> <option value="status">status</option> <option value="spin">spin</option> <option value="file_location">file location</option> <option value="upl_webgis">uploaded webgis</option> <option value="rem_upl">remarks on upload</option> </select> <input type="submit"> </form> <script type="text/javascript"> $(document).on('submit',function() { var result = ''; $('select[name="cols[]"]').find('option:selected').each(function() { result = $('select[name="cols[]"]').val(); }); alert(result); }); </script> </body> </html>
Comments
Post a Comment