js中怎样使用页面中对象的名字? eval("document.all."+str).value = "hello"; 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 为什么不直接用:<script language="JavaScript">function hello() { document.all.tmp.value="hello";}</script>或者用id来标识 <html><head><title>This is a test!</title></head><body><input type=text name=tmp><input type=button value="ok" onclick="hello()"></body></html><script language="JavaScript">function hello() { str = "tmp"; document.getElementsByName(str)[0].value="hello";}</script> <input type=text name=tmp><input type=text name=tmp><input type=text name=tmp><input type=button value="ok" onclick="hello()"><script>function hello() { var str = "tmp"; for(i=0;i<document.getElementsByName(str).length;i++) { document.getElementsByName(str)[i].value="hello"+i; }}</script> 用eval了eval("document.all."+str).value="hello" <html><head><title>This is a test!</title></head><body><input type=text name=tmp><input type=button value="ok" onclick="hello()"></body></html><script language="JavaScript">function hello() { str = "tmp"; document.all(str).value="hello";}</script> 也可以这样子.<html><head><title>This is a test!</title></head><body><input type=text name=tmp><input type=button value="ok" onclick="hello()"></body></html><script language="JavaScript">function hello() { str = "tmp"; eval("document.all."+str+".value='hello'");}</script> 跨页面控制问题 关于如何获取ifamge中的html 控件image的onclick事件?急。在线等,马上给分 如何有效修改Hta显示的Icon图标和Hta标题栏状态栏图标 如何使用JavaScript判断当前链接与现实不同,而用不用的css ? 求写一个方法,关于页面确认判断的? 这个导航栏效果,怎么实现? 如何使IFRAME内的页面随机显示 有没有办法实现把一个页面一直放在最前面 关于IE浏览器的后退问题?请诸位先贤不吝赐教。 js向jsp传值问题 模态窗口打开后,如何自动改变自身的大小 如何用js设置控件的readonly和enabled属性???????????????
<script language="JavaScript">
function hello() {
document.all.tmp.value="hello";
}
</script>
或者用id来标识
<head>
<title>This is a test!</title>
</head>
<body><input type=text name=tmp>
<input type=button value="ok" onclick="hello()"></body>
</html><script language="JavaScript">
function hello() {
str = "tmp";
document.getElementsByName(str)[0].value="hello";
}
</script>
<input type=text name=tmp>
<input type=text name=tmp>
<input type=button value="ok" onclick="hello()">
<script>
function hello() {
var str = "tmp";
for(i=0;i<document.getElementsByName(str).length;i++)
{
document.getElementsByName(str)[i].value="hello"+i;
}
}
</script>
eval("document.all."+str).value="hello"
<head>
<title>This is a test!</title>
</head>
<body><input type=text name=tmp>
<input type=button value="ok" onclick="hello()"></body>
</html><script language="JavaScript">
function hello() {
str = "tmp";
document.all(str).value="hello";
}
</script>
<head>
<title>This is a test!</title>
</head>
<body><input type=text name=tmp>
<input type=button value="ok" onclick="hello()"></body>
</html><script language="JavaScript">
function hello() {
str = "tmp";
eval("document.all."+str+".value='hello'");
}
</script>