跟你jscript的位置有关,
这样两个数值都可以的<body>
<form id="form1" name="form1">
<input type="text" name="sele" value="sele" value="sdf";>
</form>
<script>
document.write("aaa");
document.write(document.form1.sele.value);
</script></body>
这样两个数值都可以的<body>
<form id="form1" name="form1">
<input type="text" name="sele" value="sele" value="sdf";>
</form>
<script>
document.write("aaa");
document.write(document.form1.sele.value);
</script></body>
解决方案 »
- 查看别人的代码时,动态绑定的事件,如何追踪??
- 怎么将带参数的函数绑定到某个页面组件的点击事件上?
- javascript正则表达式问题
- asp.net 如何在按钮的后台的click事件中弹出前台的div遮住框架
- 急!!!关于 正则表达式 验证浮点数的问题?在线等待!
- 如何显示和隐藏层,谢谢各位?
- 谁用js内的dom把 title与link里的值取出来 最好用一个循环
- 如何实现IE右下脚的窗口?
- 【最简单的Tree】使用UL/LI,任何DOM1.0标准浏览器均可~ 顺便散100分(新手只能给这么多)
- www.blueidea.com中的“在线调查”饼图是怎么做的?
- 怎样得到INPUT 的值
- 为什么document.write()出来的函数会自动执行?
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head><form name="form1" method="post" action="">
<select name="select" onChange="show()">
<option value="1">show the first layer1</option>
<option value="2">show layer2</option>
<option selected>select one</option>
</select>
</form>
<script language="JavaScript">
<!--
function show(){
document.write("aaa")
document.write(document.form1.sele.value);
document.write(document.form1.sele.options[document.form1.sele.selectedIndex].value);
}
//-->
</script>
</body>
</html>
上面后两种document.write好象都有点问题,不知怎么回事,望指点!
document.write(document.form1.sele.value);select name错了
document.write("aaa")
document.write(document.form1.sele.value);
document.write(document.form1.sele.options[document.form1.sele.selectedIndex].value);
}
改成function show(){
document.write(document.form1.sele.value+document.form1.sele.options[document.form1.sele.selectedIndex].value+"aaa");
}
具体原因估计出在document.write上面
把document.write(document.form1.sele.value);该为
alert(document.form1.sele.value);如果还出错的话,就在每次write之后
调用alert(document.body.innerHTML);检查一下
after the document has finished loading
unless you first call the open method,
which clears the current document's window and erases all variables.Note
When document.write or document.writeln is used in an event handler,
document.close should also be used.