首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

带参数的对象有关问题

2012-02-22 
带参数的对象问题inputtype button onclick javascript:d(1) inputname tel1 type text id

带参数的对象问题
<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;

热点排行
Bad Request.