简体   繁体   English

根据表单选择限制表单提交

[英]Limit form submissions based on form selections

I have a consumer website that gives users an approval form that I want allow the users to submit their approvals but I want to limit the form number submissions based on the certain selections made and a combination of previous selections submitted.我有一个消费者网站,它为用户提供了一个批准表格,我希望允许用户提交他们的批准,但我想根据所做的某些选择和先前提交的选择的组合来限制提交的表格编号。 As of now, the users always have access to the form even after they approve it and I would like to stop submissions after they approve it.截至目前,即使在用户批准后,用户也始终可以访问该表单,我想在他们批准后停止提交。

There are 3 set of selections:有3组选择:

Set 1 [Initial Options at first, none of the other sets should be shown.]设置 1 [首先是初始选项,不应显示其他设置。]

Approve (radio button)批准(单选按钮)

Disapprove (radio button)不同意(单选按钮)

Set 2 [This set is dependent on Set 1's selection.组 2 [此组取决于组 1 的选择。 If the "Disapprove" from Set 1 is selected, then this set should be shown.如果选择了第 1 组中的“不批准”,则应显示该组。 Otherwise it will be hidden.]否则它会被隐藏。]

Revision (radio button)修订(单选按钮)

Correction (radio button)更正(单选按钮)

Set 3 [This set is dependent on Set 2's selection (and of course Set 2 being visible).设置 3 [此设置取决于设置 2 的选择(当然设置 2 可见)。 If the "Revision" or "Correction" is selected from Set 1, then show either "Revision text" or "Correction text" based on the corresponding selection from set 2.]如果从第 1 组中选择了“修订”或“更正”,则根据第 2 组中的相应选择显示“修订文本”或“更正文本”。]

Revision text (textarea)修订文本(textarea)

Correction text (textarea)更正文本(textarea)

Set 2 is dependent on Set 1's, and Set 3 is dependent on Set 2's selection.设置 2 取决于设置 1,设置 3 取决于设置 2 的选择。

Ok, these are the submission total I would like based on the selections:好的,这些是我想要的基于选择的提交总数:

  • If the user... first approves , dynamically set the total submissions to 1 .如果用户...首先批准则将总提交动态设置为 1 Form will not submit the next time, counting the current submission as 1.下次不会再提交表单,将本次提交计为1次。

  • If the user... first disapproves , dynamically set the total submissions to 2 .如果用户...首先不同意则将总提交动态设置为 2 Remaining one more submission, counting the the current submission as 1.剩余1次提交,将当前提交计为1次。

  • If the user... first approves and then disapproves , dynamically set the total submissions to 3 .如果用户...先批准然后不批准则将总提交动态设置为 3 Remaining one more submission, counting the the current submission as 1.剩余1次提交,将当前提交计为1次。

  • If the user... first disapproves and then approves , dynamically set the total submissions to 2 .如果用户...先不同意然后批准,则动态设置提交总数为 2 Remaining one more submission, counting the the current submission as 1.剩余1次提交,将当前提交计为1次。

  • If the user... first disapproves and then chooses revision , show the revision textarea and dynamically set the total submissions to 2 .如果用户...首先不同意然后选择修订,则显示修订文本区域并动态设置提交总数为 2 Remaining one more submission, counting the the current submission as 1.剩余1次提交,将当前提交计为1次。

  • If the user... first disapproves and then chooses correction , show the correction textarea and dynamically set the total submissions to 2 .如果用户...首先不同意然后选择更正,则显示更正文本区域并动态设置总提交数为 2 Remaining one more submission, counting the the current submission as 1.剩余1次提交,将当前提交计为1次。

This is the general pattern I would want to the submission limits.这是我想要提交限制的一般模式。 So basically, if the user approves they can no longer submit the form after the current submission.所以基本上,如果用户批准他们不能再提交当前提交后的表单。 If the user disapproves they are only allowed 2 additional submissions.如果用户不同意,他们只能再提交 2 次。 I haven't fully worked it out, but Im hoping to get some suggestions and help from some experts.我还没有完全弄清楚,但我希望得到一些专家的建议和帮助。

Another thing to consider are any alternatives if the user has javascript disabled and their cookies turned off (if the given solution requires them.)如果用户禁用了 javascript 并关闭了 cookie(如果给定的解决方案需要它们),则需要考虑的另一件事是任何替代方案。

To deal with "no javascript", you need to make the site work without script support.要处理“无 javascript”,您需要使站点在没有脚本支持的情况下工作。 That is always a good first step.这总是好的第一步。 All your validation and logic must be replicated on the server anyway because you have no control over the client.无论如何,您的所有验证和逻辑都必须在服务器上复制,因为您无法控制客户端。

Once you have the page working without script, you can then script the client (say by doing submissions with AJAX) to provide a more functional or efficient user interface.一旦您的页面在没有脚本的情况下工作,您就可以为客户端编写脚本(例如通过使用 AJAX 提交)以提供更实用或更高效的用户界面。

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

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