<select onchange="alert(this.options[this.selectedIndex].text)">
解决方案 »
- javascript一个令人郁闷的小问题
- jquery两种验证方式如何引用?
- JavaScript调用ActivX控件,浏览器冻结!!急!!
- 在线考试,提交后改变字体颜色和禁用checkBox
- js 数组的问题
- 求窗口关闭而引发事件的方法
- showModalDialog 问题!! 高手请进
- 如果有两个submit,如何用javascript检测单击了那个submit?
- Discuz论坛的验证码input框是怎么做到“失去焦点”自动验证的,在html里面没发现onblur啊
- 网页中能否替换script标签中src属性
- 请把下面的JSSCRIPT大小写转换程序转换成VBSCRIPT程序
- 看看这段代码:为什么zzz.html中的hidden提交不到form123.php中(PHP设置没问题(其他的都行))???
<!--
function getItem() {
alert(SelTest.options[SelTest.selectedIndex].value);
}
-->
</Script><Select Name="SelTest" OnChange="getItem()">
<Option Value="CHINA">中国</Option>
<Option Value="JAPAN">日本</Option>
<Option Value="KOREA">韩国</Option>
</Select>
<head>
<title>Option对象的属性</title>
<script language="JavaScript">
// 显示选项信息
function optionData(){
var objSelect = document.myForm.mySelect;
pos.innerText = objSelect.options[objSelect.selectedIndex].index;
content.innerText = objSelect.options[objSelect.selectedIndex].text;
show.innerText = objSelect.options[objSelect.selectedIndex].value;
}
// 更改选项名称
function changeText(objForm){
var objSelect = objForm.mySelect
objSelect.options[objSelect.selectedIndex].text = objForm.optionName.value;
}
</script>
</head>
<body>
<h2>Option对象的属性</h2>
<hr>
<form name="myForm">
<select name="mySelect">
<option value="value1" Selected>HTML</option>
<option value="value2">JavaScript</option>
<option value="value3">VBScript</option>
</select>
<input type="button" onclick="optionData()" value="选择"><br>
选项名称 : <input type="text" name="optionName">
<input type="button" onclick="changeText(this.form)" value="更改">
</form>
选项位置: <span id="pos"></span><br>
选项名称: <span id="content"></span><br>
选项值 : <span id="show"></span><br>
</body>
</html>