Today now in this post i will show you How to set multiple selected value in Chosen Jquery Plugin? Sometimes we need to set selected value in the Chosen Jquery Plugin then we can solve this by using val() with trigger(). Few days ago, i was worked with my new laravel project i was needed to set selected the value with the chosen and also multiple selected value both. I was try and then after some try i was found how to do with if set single selected value by using val().
But i was confuse with the dropdown multiple selected value, but at the last i was found how to give the value, we just need to pass array in val() just. Now as bellow i will mention both way how we could solve this issue.
Set Single Value:
var my_val = 3; $("#set-corsi").val(my_val).trigger("chosen:updated");
Set Multiple Value:
var my_val = 3,4,6; var str_array = my_val.split(','); $("#set-corsi").val(str_array).trigger("chosen:updated");
Read Also : How to Create Custom Blade Directive in Laravel?
Thanks for read. I hope it help you. For more you can follow us on facebook.