在表单提交后呈现表单 [英] Render a form after form submission

查看:147
本文介绍了在表单提交后呈现表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在提交上一个表单后呈现表单。例如,假设我有一个只有一个选择下拉菜单的表单。您选择其中一个选项,然后点击继续(提交按钮),页面重新加载后会根据所选类别显示一个新表单。

I am trying to render a form after a previous form is submitted. For instance, let's say I have a form that only has a select dropdown menu. You choose one of the options, click 'continue' (the submit button) and after the page reloads, it renders a new form depending on the chosen category.

FYI,我试图在Rails应用程序中这样做。

FYI, I am trying to do this in a Rails App.

这里是一个例子: http://popcornindiana.com/contact-us

推荐答案

逐页示例。如果你打算这样做,那么你的表单应该提交到另一个页面,然后它的下一个形式作为一个单独的文档。注意当你提交一个表单时,URL是如何变化的。它完全不同的页面。

The example you provided is a page-by-page example. If you're looking to do that, then your form should submit to another page, which then has the next form on it as a seperate document altogether. Note how when you submit one form, the URL changes. Its a different page entirely.

现在,如果你正在寻找单页表单(你点击提交和页面不刷新,而是表单刷新),您希望使用异步表单提交。有很多方法可以做到这一点,包括滚动自己的,使用jQuery或像AngularJS这样的大型框架。

Now, if you're looking to do single-page forms (where you hit submit and the page doesn't refresh, but rather the form refreshes), you're looking to use asynchronous form submission. There are many approaches to doing this, including rolling your own, using jQuery, or a large framework like AngularJS.

这两种可能的方法,您的要求取决于您。

Those are the two possible approaches, which you choose based off your requirements is up to you.

我会查找任何一种方法的教程;问题的性质表明你可能在这方面没有经验,所以我会说看如何提交表格的教程,然后决定后来的方式。

I would look up tutorials on either method; the nature of the question indicates that you may be fairly inexperienced in this so I'd say look up tutorials on how to submit forms, and then decide which way to go after that.

这篇关于在表单提交后呈现表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆