JS如何访问多个对象,帮忙啊

rkongjian 2003-09-04 10:00:03
我在表单中用程序创建了系列对象,比如系列用户输入栏usrdescrip1, usrdescrip2, usrdescrip3...,现在判断某对象的(输入)值是否空,if (form.usrdescrip1=="") ...,由于很多想用循环依次判断,不知应该怎么写,请帮忙,万分感谢
...全文
98 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
lshdic 2003-09-04
  • 打赏
  • 举报
回复
ONE:

<form id='form1'>
<input name='a' type='text'><input name='b' type='text'><input name='c' type='text'><input name='d' type='text'>
<input type='button' onclick='for(i in form1.all.tags("INPUT")){if(form1.all.tags("INPUT")[i].type=="text")alert(form1.all.tags("INPUT")[i].value)}'>
</form>

TWO:

<form id='form1'>
<input name='a' type='text'><input name='b' type='text'><input name='c' type='text'><input name='d' type='text'>
<input type='button' onclick='for(i=0;i<form1.all.tags("INPUT").length;i++){if(form1.all.tags("INPUT")[i].type=="text")alert(form1.all.tags("INPUT")[i].value)}'>
</form>
hrong 2003-09-04
  • 打赏
  • 举报
回复
不会吧, 这个问题竟然搁在论坛里半个小时没有理? 算了, 我还是答答吧:

for(var i=1; i<4; i++)
{
if(eval("document.formName.usrdescrip"+ i).value == "")
//................
}

87,988

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧