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> jquery和javascript代码混合使用时取不到变量的问题(续)变量作用域 div中嵌套img不能填充完整的问题! 菜鸟提问 :EXt 框架中菜单访问面板出错 怎么读取数据库里的图片 ★怎样改变下拉菜单文字的颜色??急 请问怎么得到这个值? 跪求。。。。如何实现iframe滚动条自动下滚? COOKIE 问题 jquery如何随机向li添加文字内容? 判断点击元素的索引值,比如jquery的index函数 模态窗口打开后,如何自动改变自身的大小 如何用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>