获取最后一项

时间:2011-04-11 10:35:34

标签: asp-classic

如何获取ASP中选定HTML元素中的最后一项?

<select id="AggregationLevel" name="AggregationLevel" onchange="javascript:SF(true)">


                                <option  value="1">Monthly</option>

                                <option  value="2">Weekly</option>

                                <option  selected='selected'  value="3">Daily</option>


                </select>

1 个答案:

答案 0 :(得分:1)

var i = document.getElementById("AggregationLevel").options.length;
var j = document.getElementById("AggregationLevel").selectedIndex;
alert(document.getElementById("AggregationLevel").options[i-1].value); // last item
alert(document.getElementById("AggregationLevel").options[j].value); // selected item, if this is what you're  interested in