1 year ago

JQuery: How to select an individual option in a drop down select

Posted 1 year ago by vincej

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>


$("select.edit_cat").on("click",function() {
           {$(".category_alert").html('<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</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">&times;</a><strong>WARNING:</strong> Message Two ').addClass("alert alert-danger alert-dismissible")}

Please sign in or create an account to participate in this conversation.