简体   繁体   English

在页面上提交所有输入元素

[英]submit all input elements on a page

Is there an easy way to submit all input elements on a page? 有没有一种简单的方法可以在页面上提交所有输入元素?

I have a very customisable page where the user can add and remove rows from multiple tables. 我有一个非常可定制的页面,用户可以在其中添加和删除多个表中的行。 The rows contain various different input elements. 这些行包含各种不同的输入元素。 Do I have to put each table inside a form and then on submit have javascript to submit all the forms? 我是否必须将每个表放入表单中,然后在提交时使用JavaScript提交所有表单?

If you want to submit all input elements, it's sufficient to have only one <form> that encircles them all. 如果要提交所有输入元素,仅用一个<form>包围它们就足够了。 Calling form.submit() from JS or with a classic submit button then catches all input fields. 从JS或使用经典的form.submit()按钮调用form.submit()会捕获所有输入字段。

If you want a dynamic selection by the user, let her put inputs inside the form element for submission and outside to keep them where they are. 如果要由用户动态选择,则让她将输入内容放置在要提交的form元素内,并在外部放置以将其放置在原处。 This can be achieved with JavaScript. 这可以使用JavaScript来实现。

只需在包含所有表和输入的页面上放置一个表单,然后提交即可-您一次不能提交多个表单。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM