如何动态增加输入框

zqpsswh 2005-10-31 07:38:16
我最近做一个系统 里面有个出库单模块

因为每次都不止一个货物出库 所以需要动态的添加一个输入框 如下格式

单号 类别 名称 数量


现在问题来了 我的类别和名称 是对应的用showModalDialog打开新窗口搜索数据库,用window.returnValue返回相应值

我要是动态的添加了一个窗口 在新增的输入框里用showModalDialog
就无法显示了 我判断是因为两个输入框的 input name 相同导致
请问下 我应该如何设计呢?

...全文
331 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
zqpsswh 2005-11-01
  • 打赏
  • 举报
回复
一楼的办法不行 因为我返回的值是一个数组

二楼的 我用了 但是他老说docm.form.type[..]之类的为空或不是对象
安迪 2005-11-01
  • 打赏
  • 举报
回复
我想二楼的方法是不是你有个地方漏掉了,就是极限的情况,比如只有一个"<input name="abc" id="abc" value="aaaa">"那就不会形成数组,当然用"document.form1.abc
  • .value"的方法根本没有办法来识别,所以最好做个判断用"document.form1.abc.length"如果这个只是undefine(不能写成=="undefine",要写成==undefine)如果成立就"document.form1.abc.value",不成立就用二楼的方法。我想就可以了!
matrixy 2005-10-31
  • 打赏
  • 举报
回复
你打开模态对话框时再另传一个参数,就用这个文本框的索引值,因为同名的INPUT会形成一个集合,就像是一个数组,再次给INPUT赋值的时候,就以索引值直接的访问该INPUT...

比如
<form name="form1" id="form1">
<input name="abc" id="abc" value="aaaa">
<input name="abc" id="abc" value="aaaa">
</form>

document.form1.abc[0].value
document.form1.abc[1].value

就看你怎么组织了,像这种事其实还是很好办的.
梅雪香 2005-10-31
  • 打赏
  • 举报
回复
vReturnValue = window.showModalDialog(sURL [, vArguments] [, sFeatures])

vArguments :
Optional. Variant that specifies the arguments to use when displaying the document. Use this parameter to pass a value of any type, including an array of values. The dialog box can extract the values passed by the caller from the dialogArguments
property of the window object.

把打开ModalDialog的对象直接传到ModalDialog里就好了

87,904

社区成员

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

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