JavaScript之内部数组
1、文档表单数组
文档中所有表单,构成的数组。
<html><head></head><body>
<form id="first"></form>
<form id="second"></form>
<form id="thrid"></form>
<script type="text/javascript"><!-- 或者<script language="javascript"> -->
var fs = document.forms;
for (i = 0; i < fs.length; ++i) {
alert(fs[i].id);
}
</script>
</body></html>
2、选择列表的选项数组
<html><head></head><body>
<form id="first">
<select name="object" onclick="test()">
<option value="china">中国</option>
<option value="us">美国</option>
<option value="uk">英国</option>
</select>
</form>
<script type="text/javascript"><!-- 或者<script language="javascript"> -->
var object = document.getElementById("object");
for (i = 0; i < object.options.length; ++i) {
alert(object.options[i].value + ", " + object.options[i].text);
}
</script>
</body></html>