javascript - Jquery chosen plugin to post the values, On the order which user selected the data in multiple box -


i have query if user select options in multi select box(choosen plugin) should post page order selected user.

for e.g. have following code

<select name="city" multiple data-rel=​"chosen" > <option value="1">mumbai</option> <option value="2">pune</option> <option value="3">nagpur</option> <option value="4">nashik</option> </select> 

if user select in following order nagpur,pune,nashik , mumbai posting values page following manner 1.2,3,4( sorted).

but, post page order selected user i.e. 3,2,4,1

please help..

thanks in advance

chosen order plugin chosen aims provide functions handle order of selection.

https://github.com/tristanjahier/chosen-order

update:

<script type='text/javascript'> var results = []; $("#city").on('change',function(){     var selected_values = $(this).val();     var temp_results = results;     results = [];      //for removed values     for(i in temp_results){         if($.inarray(temp_results[i],selected_values)>=0){             results.push(temp_results[i]);         }     }      //for added values     for(i in selected_values){         if($.inarray(selected_values[i],temp_results)<=-1){             results.push(selected_values[i]);         }     }                     console.log(results.join("::"));     //save in hidden input pass next page }); </script> 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -