您现在的位置是:首页 > 电脑技术查询 > web开发

带参数的对象有关问题

编辑:chaxungu时间:2022-10-02 23:20:15分类:web开发

带参数的对象问题
<input type= "button " onclick= "javascript:d(1) ">
<input name= "tel1 " type= "text " id= "tel "/>
<input type= "button " onclick= "javascript:d(2) ">
<input name= "tel2 " type= "text " id= "tel "/>
<input type= "button " onclick= "javascript:d(3) ">
<input name= "tel3 " type= "text " id= "tel "/>
<script>
function d(i)
{
a=form1.(tel+i).value;
alert(a);
}
</script>

好像不能(tel+i)这样子写,请帮帮忙.谢谢!

------解决方案--------------------
a=eval( "document.form1.tel " + i + ".value ");
或者
a = document.form1.elements[ "tel " + i].value;