表示一個(gè)列表框或者一個(gè)下拉框。
Denotes a list box or drop-down list.
此元素在 Internet Explorer 3.0 及以上版本的 HTML 中可用。
此元素是窗口控件,不支持 z-index 或者 zIndex 屬性。
此元素是內嵌元素。
此元素需要關(guān)閉標簽。
The SELECT element is available in HTML and script, as of Internet Explorer 3.0.
This element is a windowed control and does not support the z-index attribute or zIndex property.
This element is an inline element.
This element requires a closing tag.
下面的例子使用 SELECT 元素創(chuàng )建了一個(gè)下拉列表框。
This example uses the SELECT element to create a drop-down list box.
<SELECT NAME="Cats" SIZE="1">
<OPTION VALUE="1">Calico
<OPTION VALUE="2">Tortie
<OPTION VALUE="3" SELECTED>Siamese
</SELECT>
下面的例子使用 select 元素創(chuàng )建了多項選擇列表框,方法是設置了 SIZE 和 MULTIPLE 標簽屬性。要獲得多項選擇列表框的選中選項,則須遍歷 options 集合并檢查 SELECTED 是否被設為 true。
This example uses the select element to create a multi-select list box by setting the SIZE and MULTIPLE attributes. To retrieve the selected options for a multi-select list box, iterate through the options collection and check to see where SELECTED is set to true.
<SELECT ID="oSelect" NAME="Cars" SIZE="3" MULTIPLE>
<OPTION VALUE="1" SELECTED>BMW
<OPTION VALUE="2">Porsche
<OPTION VALUE="3" SELECTED>Mercedes
</SELECT>
下面的例子在上面創(chuàng )建的 SELECT 列表的底部添加了一個(gè)新選項。新選項的構造程序也可在 Microsoft JScript? 中使用。
This example adds a new option to the end of the SELECT list created above. The new Option constructor can also be used in Microsoft JScript.
<SCRIPT LANGUAGE="JScript">
var oOption = document.createElement("OPTION");oOption.text="Ferrari";
oOption.value="4";
oSelect.add(oOption);
</SCRIPT>
聯(lián)系客服