mootools 克隆表单元素
我无法获取表单来提交已克隆的其他字段。当提交如下所示的表单时,它不包含克隆的表单元素。有谁知道为什么以及如何缓解这个问题。
<form>
<table>
<tr><td><input type="text" value="50" name="myvar[]" /></td></tr>
<!-- This button will clone the previous set of form elements -->
<tr><input type="button" value="Add New Line" onclick="this.getParent('tr').getPrevious('tr').clone().inject(this.getParent('tr'), 'before')" /></tr>
</table>
</form>
I cannot get a form to submit additional fields that have been cloned. When a form like the one below is submitted, it does not include the cloned form elements. Does anybody know why and how I can alleviate this issue.
<form>
<table>
<tr><td><input type="text" value="50" name="myvar[]" /></td></tr>
<!-- This button will clone the previous set of form elements -->
<tr><input type="button" value="Add New Line" onclick="this.getParent('tr').getPrevious('tr').clone().inject(this.getParent('tr'), 'before')" /></tr>
</table>
</form>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的 HTML 格式不正确,因此
this.getParent('tr')
至少在 Firefox 中返回null
。将按钮放入tr
内的td
内即可工作。JSFiddle:http://jsfiddle.net/delvarworld/r99fN/ 单击按钮会引发错误
Your HTML isn't well formed, so
this.getParent('tr')
is returningnull
at least for me in Firefox. Put the button inside atd
that is inside thetr
and it works.JSFiddle: http://jsfiddle.net/delvarworld/r99fN/ clicking the button throws an error
感谢您的评论,但该表格只是一个示例,而不是我实际拥有的。我回头查看表单,顶部表单元素位于表格内部,底部表单元素位于表格外部。我将顶部表单元素移到了表格之外,一切都运行良好。
谢谢,
Thanks for the comment but the form was meant to be an example not actually what I had. I looked back at the form and the top form element was inside the table and the bottom form element was outside of the table. I moved the top form element outside of the table and everything works perfectly.
thanks,