<input id="test1">
<input id="test2">
<input id="test3">
<input id="test4">
<SCRIPT LANGUAGE="JavaScript">
for (var i=1;i<=4;i++)alert(eval("test"+i).id)
</SCRIPT>
<input id="test2">
<input id="test3">
<input id="test4">
<SCRIPT LANGUAGE="JavaScript">
for (var i=1;i<=4;i++)alert(eval("test"+i).id)
</SCRIPT>
解决方案 »
- 关于页面取值的问题
- 很怪异的一个浏览器兼容问题
- js有没有等元素都填允完成后再执行的方法。
- js右键启动收藏夹
- one+a.style.background="#f00"; a参数1 id是one1。这样写不对help!
- 怎么打印预览及打印页面嵌入的百度地图
- xtree(http://webfx.eae.net/dhtml/xtree/)在Frame中的对齐问题
- 如何在当前窗口背后弹出窗口
- 升5个等边三角行,散200,
- 问各位专家了!小case的问题了.在线等待了!
- 能写个将12345678.99转换成12,345,678.99 的javascript金额处理函数吗,巨急
- 高手请进,请问如何把要投票选定的产品的值传递到相应的文本框中。
例如验证表单,input name 为cj0 cj1...
<script language="javascript">
<!--
function check(form)
{
var a=Number(form.cj_num.value);//转换成int
var i;
for(i=1;i<=a;i++)
{
var b="cj"+i;
alert(document.all(b).value); // var b=eval("form.cj"+i);都可以
}
}
</script>
eval('aaa' + 1).focus(); 相当于:aaa1.focus();
所以参数可以是任何对象
**********************
[This topic is part of a beta release and is subject to change in future releases. Blank topics are included as placeholders.]Evaluates JScript code and executes it. eval(codeString)
The required codeString argument is a string value that contains valid JScript code. This string is parsed by the JScript parser and executed.Res
The eval function allows dynamic execution of JScript source code. For example, the following code creates a new variable mydate that contains a Date object: eval("var mydate = new Date();");
The code passed to the eval method is executed in the same context as the call to the eval method.