【发布时间】:2018-01-05 13:20:13
【问题描述】:
我有两种形式
-
first_form用于 ajax 请求以加载新的输入数据,这些数据显示在second_form中作为输入字段(这已经完成) -
second_form是提交自己的所有数据,first_form也是(这个没实现)
first_form 使用form-inline 水平显示输入,而另一种形式是普通形式,因此我无法将这两种形式结合起来。
所以当用户点击second_form 的提交按钮时,我想将其所有数据连同first_form 的数据一起发送。
例子:
<form id="first_form" class="form-inline">
<input type="text" />
<input type="text" />
<button type="submit" class="btn btn-primary">Load</button> // This loads fields for second form
</form>
<form id="second_form">
<div class="loaded_data"> // this div is loaded with ajax
<input type="text" />
<input type="text" />
<button type="submit" class="btn btn-primary">Save</button> // This must send all fields of first and second form
</div>
</form>
我不想将 ajax 用于第二种形式。将提交表单并调用 Laravel 控制器的 store 方法进行进一步处理
【问题讨论】:
-
为什么不直接使用 AJAX 调用?
-
我们总是乐于帮助和支持新的编码员,但您需要先帮助自己。 :-) 在doing more research 之后,如果您有问题发布您尝试过的方法,并清楚地解释什么不起作用并提供a Minimal, Complete, and Verifiable example。阅读How to Ask 一个好问题。请务必take the tour 并阅读this。
-
@Raj 这是链接,请尝试使用此stackoverflow.com/questions/7843355/…
-
@JayBlanchard 我正在使用 laravel,它会在提交第二个表单时调用 store 方法。所以我希望它是一个正常的表单提交而不是 ajax
-
你不相信给表单元素一个名称属性吗?
标签: php jquery html forms laravel