问题标签 [multi-step]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
534 浏览

php - 多步骤表格和处理敏感数据?

我目前在我的 CodeIgniter 应用程序中设置了一个多步骤表单,我只是想知道设置它的最佳方法,因为它会保存敏感数据。目前我有一个 5 页的表单,它使用 ajax 来验证每个步骤,然后重定向到下一步。我在每个步骤中都包含了一个“后退”按钮,表单中填充了他们刚刚从我创建的数据库会话中输入的数据,我只是想知道这是否是明智之举?或者我是否应该限制他们不能返回到上一步,即使这可能会让用户感到沮丧。我正在销毁表单提交的会话。

提前致谢 :)

0 投票
2 回答
129 浏览

php - 从 MySQL 编码 Json

所以我试图从 MySQL 编码为 JSON,我需要 [pagenumber][id,type,description][answerid,answerdescription] 格式。这样做的目的是读取 javascript 文件中的数据,该文件将为我生成多步投票。

我将尝试在此处绘制一个伪代码,说明我希望它的外观:

这是我到目前为止得到的,但我似乎想不出一种方法来添加第三个“维度”,我想要一个 [id => (int), description => (string)] 的数组对每个问题。每个问题都需要空间来容纳与其相关的多个答案。answers/options 数组中的最后一列是文本字符串(大多数答案由 ID 号回答,但有些是需要整个字符串的文本区域)。这可能不需要,因为我可以通过序列化将表单结果发回。

结果如下(前 3 页)。

0 投票
2 回答
498 浏览

javascript - 如何使用 Jquery 逐步获取 PHP 数据?

我对带有 php 组合的 jquery 有一点问题。让我从代码开始。

PHP代码:

代码输出: 例如 files->number = 2 那么输出将是 50 100。

jQuery代码:

问题:我想要的是先alert 50,然后alert 100,我的意思是当第一个循环在php中结束并回显第一个进度值时,jquery应该能够拦截它,但是jquery在整个循环之后警告数据完成,这意味着我在一个警报中得到 50100,jQuery 有什么办法可以处理这个吗?我知道还有其他解决方案使用 PHP 并生成例如隐藏 div 或属性中的循环数,然后在 jQuery 中使用循环,但我真的很想直接做。

0 投票
2 回答
1137 浏览

ruby-on-rails-3 - Rails 3、大型多步形式:1个大型控制器还是按资源分开?

我有一个多步骤表单,用户在几个不同的页面上填写信息。在传统的 Rails 中,您将每个资源单独保存在其自己的控制器中,并使用 REST 操作来操作数据。

在传统系统中,我将有 3-5 个不同的控制器(一些步骤是可选的)用于单个多步骤形式。如果我按照传统方式进行操作,那么控制器中就没有真正意义上的“秩序”。进入该项目的新开发人员必须了解哪些步骤映射到哪些步骤等等。

另一方面,我曾想过打破常规,使用一个控制器来组织整个多步骤表单。该控制器将充满以下方法:

这个单一的控制器会变得相当长,但它本质上是一堆耦合的方法:一个用于显示步骤(表单),另一个用于更新和重定向到下一步。

这将打破 Rails 约定,我必须设置自己的路由。

但我很好奇其他人是如何解决这个问题的?我知道两者都可以工作,但我想知道从长远来看哪个更容易维护和编码。

0 投票
1 回答
6370 浏览

asp.net-mvc - Best practice/design for a multi-page form in .NET MVC3

I am working on a web application that involves the user filling out a multi-step form that spans several pages. The form has tabbed navigation across the top (these links do not submit the current page) and a next button at the bottom (which does submit). I am considering several strategies for handling form submission/validation:

  1. one action method and view per form page. When you hit next, it submits the form to the action method for the next page. If there are validation errors, you are redirected back to the previous page:

    • URL's are descriptive and can be copy-pasted
    • Only redirects in the error case
    • Since the redirect does not have the form data, we lose context about the submission which makes it hard to display certain error messages
    • The same validation logic works for redirecting the user if they try to visit a step in the flow that they aren't ready for yet
  2. one action method and view per form page. When you hit next, it submits the form to the current page action. If there are validation errors, the same view is returned. Otherwise, we redirect to the next page action:

    • URL's are descriptive and can be copy-pasted
    • Redirects are very common (not sure if this is bad)
    • When displaying validation errors, we are in the same request as the form submission so we have full access to the invalid input
    • Have to pass additional context if we want the ability to, for example, add a "Previous" button which also submits
  3. one action method for ALL pages. URL's contain additional context about the step being submitted (e.g. MyController/MyAction/{step}). The controller message selects which view page to return depending on validation and the current step.

    • URL's are not descriptive (e. g. if I submit step 1 to go to step 2, then the URL the user sees will be the same regardless of whether page 1 (invalid) or page 2 is returned
    • No redirects
    • When displaying validation errors, we are in the same request as the form submission so we have full access to the invalid input
  4. A different method I haven't listed here

I have tried to enumerate what I see as some of the pros and cons of each method, but I would be interested to know:

  • What are other pros and cons of these methods? Are mine correct? Could some of the cons I've listed be designed around?
  • Is there a standard approach to this problem which I should be using? If so, why is it the standard approach?
0 投票
3 回答
281 浏览

php - 我如何知道在 HTML 表单中选择了哪个选项?

我想要一个包含 HTML 和 PHP 的多步骤表单。我的表单的第一步是一个选项,例如:

现在,我的问题是:如何知道选择了哪个选项,以便为用户安排下一步选项?

例如:如果用户选择选项 1,下一步将是:“你选择了选项 1,告诉我谁是你的爸爸”。如果用户选择选项 2,下一步会说:“欢迎使用选项 2,告诉我你喜欢什么”等。

现在,我完全是 PHP/HTML 的初学者,对 javascript 一无所知。如果您要回答这个问题,我将非常感激,但请以易于理解的方式回答。

我已经发现与我的案例有关,但是很难自定义,并且验证过程是 CSS3 之前的。

[编辑:]

现在我想像这样添加一个文本类型的输入:

这些人告诉我要使用$_POST['fname'],但对于输入文本,“值”属性将像默认标题一样显示在文本框内。我不想要这个。

现在你有什么建议?

0 投票
3 回答
570 浏览

ruby - Ruby on Rails 使用标签

每个人!

起初,我制作了一个包含大量元素的表单:文本字段、文本区域等。准备好表格后,我才明白,这么大的表格要连续填写,不太方便。我不想使用“步骤”系统(步骤 1 -> 步骤 2 -> ... -> 步骤 n),因为我希望最终用户能够以任何顺序填写此表格( + 用户可以预先看到他需要填写哪些表格),所以我将表格分成了几个选项卡

这个想法如下:一旦用户在某个选项卡中填写了表单,他点击“保存”按钮并继续到下一个(以他选择的任意顺序)。

我想知道 - 存储中间数据的最佳方法是什么?我是否应该为每个带有选项卡 ID 的选项卡表单设置一些隐藏输入以传递给模型,以便在每个“步骤”中仅验证选项卡相关数据并将其存储在数据库中。或者,也许,我应该有一个包含当前对象的 session[:object],最后我会将它存储在 DB 中并从会话中删除。

这个想法能实现吗?

提前致谢!:)

0 投票
3 回答
925 浏览

php - 如何在php中将一个巨大的进程分成多个步骤?

我需要处理一个 xml 文件并将一些数据相应地插入到我的数据库中。由于 XML 文件包含接近 10000 行并且可能有几千行要插入到数据库中,我担心我的脚本会超过max execution time.

我见过一些脚本来防止这种情况,它们将整个过程分成更小的步骤,脚本每隔几秒钟刷新一次页面,它会继续它正在做的任何事情。

我只是想知道它是怎么做到的?

0 投票
0 回答
395 浏览

validation - 如果下一步的确认字段,如何以多步形式验证确认?

我使用client_side_validations-formtasticclient_side_validations宝石。

在我的模型中:

通知

new_attendee_confirm

#new_attendee_save我添加了用于多步表单验证的脚本(如果我validates_confirmation_of从模型中删除它会起作用):

我需要这个逻辑。用户在第一步填写表单,这会触发除确认之外的所有验证。接下来,用户单击保存按钮,它显示了一些协议,并作为签名提示输入孩子和父母的姓名。在这些字段中,验证应该适用于存在和确认。有没有办法实现这个场景?

以我的方式,如果我添加validate: { confirmation: false }到第一步它不起作用并且仍然显示消息与确认不匹配。

0 投票
1 回答
778 浏览

forms - 多步表单验证 Codeigniter

是否可以在 Codeigniter 中运行多步表单验证,这样,当发现错误时,表单验证将停止(不验证其他表单验证规则)?

使用 Form_validation 类的 set_rules() 和 run() 方法,即使没有通过第一个规则,也会检查所有规则。

还是以特定顺序在我的模型中验证这些标准(这样它在验证错误时停止)并将单个错误消息传递给我的视图是否更好?