I'm wondering if it's possible to store the selected values from a <select>
in a JS array.
What I finally need to do is calculate the highest 6 values out of around 10 dropdowns, which I think I can do by using the JS Math.max() function.
Help is greatly appreciated.
Here is some sample code:
<? while($subjects = mysql_fetch_array($query)) { ?>
<select class="points">
<optgroup label="<?=$subjects['name']?>">
<option value="100">A1</option>
<option value="90">A2</option>
<option value="85">B1</option>
<option value="80">B2</option>
<option value="75">B3</option>
</optgroup>
</select>
<? } ?>
<script>....
This assumes that all the
select
s on the page should be included. If that isn't the case, then you should usedocument.getElementsByClassName
or a similar, more appropriate selector instead.Demo
Do something like this (JQuery):
Try this: