Ok so I have this code that is able to select and count the amount of select boxes that have a specific option selected. However, I want to change it to groups. I have 3 groups of drop downs, and they are currently in
<div class"groupA">
etc.
What I want to do is get the counts from each group. how can I modify this script to count selected only within a certain group on the page? right now it works but counts how many are selected on the entire page.
<script type="text/javascript">
function getSelectedValues(){
var matches = $('select').filter(function(){
return $(this).val() == '5';
}).length;
// here's where we just update that new <span>
$('span#result5').text(matches);
}
// and here we bind to the change event for the selects
// and re-call our above function.
$('select').on('change', getSelectedValues);
</script>
<span id="result5"></span>
Second, right now that span id=result displays the amount of times that specific option was selected. instead, I want it to change text color to red if the amount counted is over 1. so here is my poor example of what I want it to do:
<span id="result5"></span>
This select name <-- how it displays when 0, or 1 are selected
<font color="#FF0000">This select name</font>
^-- how it displays when 2 or more are selected