form
Select form 属性
定义和用法
form 属性可返回对包含该下拉列表的表单元素的引用。
该属性返回 form 对象。
语法
selectObject.form
浏览器支持
所有主要浏览器都支持 form 属性
实例
显示包含下拉列表的表单id:
<html>
<head>
<script>
function displayResult()
{
var x=document.getElementById("mySelect").form.id;
alert(x);
}
</script>
</head>
<body>
<form id="form1">
Select your favorite fruit:
<select id="mySelect">
<option>Apple</option>
<option>Orange</option>
<option>Pineapple</option>
<option>Banana</option>
</select>
</form>
<button type="button" onclick="displayResult()">Display id of container form</button>
</body>
</html>
<head>
<script>
function displayResult()
{
var x=document.getElementById("mySelect").form.id;
alert(x);
}
</script>
</head>
<body>
<form id="form1">
Select your favorite fruit:
<select id="mySelect">
<option>Apple</option>
<option>Orange</option>
<option>Pineapple</option>
<option>Banana</option>
</select>
</form>
<button type="button" onclick="displayResult()">Display id of container form</button>
</body>
</html>