<html><head><script>
function getValue()
{
var tt=document.getElementsByName("select1");
alert (tt[0].getAttribute("value"));
}
</script></head>
<body>
<form name="form1">
<select name="select1" onChange="getValue()">
<option value="1">1</option>
<option value="2">2</option>
</select>
</form>
</body></html>
function getValue()
{
var tt=document.getElementsByName("select1");
alert (tt[0].getAttribute("value"));
}
</script></head>
<body>
<form name="form1">
<select name="select1" onChange="getValue()">
<option value="1">1</option>
<option value="2">2</option>
</select>
</form>
</body></html>
解决方案 »
- html表单 文件组件 限制文件类型?
- 这样的操作属于跨域操作吗?这里的域到底指哪个域?
- var x= function(){} 这种方法写的函数好处在哪里
- 如何更方便写javascript脚本
- 控制RealPlayer的问题
- 簡單的不能關閉窗口辦法
- 求教在JavaScript中取消浏览器关闭事件的问题
- 我想让用户访问我得服务器端程序时 IE地址栏显示出来 但不允许用户在IE地址栏内自己输入IE地址
- 如果何能使iframe的大小随着它包含的网页里面的table大小变化而变化?急切!!!
- 简单:怎么样让多个复选框全选???
- 哪里错了呀 就是运行不了.
- 请教~~~敏感代码怎么在HTML里原原本本的显示出来
function getValue()
{
var tt=document.getElementsByName("select1");
alert("length: " + tt.length);
alert("value: " + tt[0].value);
}
</script></head>
<body>
<form name="form1">
<select name="select1" onChange="getValue()">
<option value="1">1</option>
<option value="2">2</option>
</select>
</form>
</body></html>
function getValue()
{
var tt=document.getElementById("select1").value;
alert (tt);
}
</script></head>
<body>
<form name="form1">
<select name="select1" onChange="getValue()">
<option value="1">1</option>
<option value="2">2</option>
</select>
</form>
</body></html>
2、“getElementsByName”得到的是个数组,name允许重名。
<html><head><script>
function getValue()
{
var tt=document.getElementsByName("select1")[0].value;
alert (tt);
}
</script></head>
<body>
<form name="form1">
<select name="select1" onChange="getValue()">
<option value="1">1</option>
<option value="2">2</option>
</select>
</form>
</body></html>