Javascript商店< select>数组中的下拉值 [英] Javascript store <select> dropdown values within array
本文介绍了Javascript商店< select>数组中的下拉值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道是否可以在JS数组中存储来自< select>
的选定值。
I'm wondering if it's possible to store the selected values from a <select>
in a JS array.
我最终需要做的是计算大约10个下拉列表中的最高6个值,我认为我可以通过使用JS Math.max()函数来完成。
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.
非常感谢帮助。
以下是一些示例代码:
<? 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>....
推荐答案
做这样的事情(JQuery):
Do something like this (JQuery):
var selected = new Array();
$('.points option:selected').each(function() {
selected.push($(this).val());
});
这篇关于Javascript商店< select>数组中的下拉值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文