@vincej see if this helps, I haven't done dropdown in jquery. https://stackoverflow.com/questions/3243476/how-to-get-multiple-select-box-values-using-jquery
Mar 20, 2019
6
Level 15
JQuery: How to select an individual option in a drop down select
I have a table with many rows. Each row, contains a drop drown select with only two 2 options. When the user selects "active" he gets an alert message. If he selects deactivated, he gets a different alert message. The code I have works badly. It only shows one single alert no matter which option is selected. Secondly, the .on(click function()) only fires once per page refresh. I have checked SO a million times, and tried every thing known.
Any advice ? Many thanks !!
From the VIew
<td class="category_select" style="text-align: center">{{ Form::select("category_value[]",['active'=>'Active' ,'deactivated' => 'Deactivated'],$category->status,['class'=>'edit_cat form-control'])}}</td>
JQuery
$("select.edit_cat").on("click",function() {
if($('select[name="category_value[]"]').find('option:contains("activated")').prop("selected",true))
{$(".category_alert").html('<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a><strong>INFO:</strong> Message One ').addClass("alert alert-info alert-dismissible")}
else{ $(".category_alert").html('<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a><strong>WARNING:</strong> Message Two ').addClass("alert alert-danger alert-dismissible")}
});
Please or to participate in this conversation.