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

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -