Can someone help me loop through all the select dropdowns in a form and return the value selected? The number of dropdowns could vary for each form. Here's my form:
<form class="form-horizontal" role="form" id="select_distributor_form">
{{#each context.supplier}}
<div class="form-group">
<label class="col-sm-2 control-label">{{supplier_name}}</label>
<div class="col-sm-10">
<select class="form-control">
<option selected disabled>Select distributor</option>
{{#each ../context.distributor}}
<option value="{{distributor_id}}">{{distributor_name}}</option>
{{/each}}
</select>
</div>
</div>
{{/each}}
</form>
So far, I have come up with:
$("select option:selected").each(function(i, obj){
alert($(this).val());
});
However, this will loop through all the dropdowns on the entire page. I only want to loop through dropdowns in the form.. Can someone help?
Thanks in advance!