简体   繁体   English

我怎样才能使 HTML/NodeJS 表单根据响应转到另一个表单,有点像 Google 表单的“根据答案转到部分?”

[英]How can I make an HTML/NodeJS form go to another form based on a response, sort of like Google Form's "Go to section based on answer?"

So I have a NodeJS site and on the home page is a form containing some radio buttons.所以我有一个 NodeJS 站点,主页上有一个包含一些单选按钮的表单。 When the user clicks "Submit," I would like for the user to be redirected to another page based on the answer.当用户单击“提交”时,我希望根据答案将用户重定向到另一个页面。 This I have figured out (The buttons have an onclick attribute that changes the action attribute of the form element).我已经弄清楚了(按钮有一个onclick属性,可以更改表单元素的action属性)。 However, I need to keep the data from the original form, so that after the user has "chosen their path," I know what path the took and the answers they made along it.但是,我需要保留原始表单中的数据,以便在用户“选择他们的路径”之后,我知道他们选择了哪条路径以及他们沿着这条路径做出的答案。 Thank you in advance!先感谢您!

You could persist the client's state in a session.您可以在会话中保留客户端的状态。 If you're using express, one alternative could be express-session .如果您使用的是 express,另一种选择是express-session The way it works is that it assigns a unique identifier to the user in the form of a cookie and saves the data somewhere (memory, database, a file, etc. depending on which you choose).它的工作方式是,它以 cookie 的形式为用户分配一个唯一标识符,并将数据保存在某个地方(内存、数据库、文件等,具体取决于您选择的位置)。 Then when the client makes another request, the server gets that data back with the identifier from the cookie.然后,当客户端发出另一个请求时,服务器会使用 cookie 中的标识符取回该数据。

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

相关问题 如何从电子表格中编写Google表单脚本以根据答案转到特定页面? - How can I script a Google Form from a Spreadsheet to go to a specific page based on an answer? 如何选择表格到另一个页面? - How do I make a form selection go to another page? Javascript如何基于另一个表单制作表单 - Javascript how to make an form based on another form 根据答案重定向表格 - redirect form based on answer 如何开始为外部站点调用基于JavaScript的表单 - How to go about calling a javascript based form for external site 如何使用提交按钮组合值添加多个下拉表单并将另一个 html 页面名称添加到 go - How to add multiple dropdown form with submit button combine value and make another html page name to go to it jQuery 和 HTML,如何根据另一个表单的值隐藏表单? - jQuery and HTML, how to hide form based on value of another form? 如何根据表单分数获取提交按钮以转到不同的页面? - How do I get my submit button to go to different pages based on a form score? 如何根据特定条件使 HTML 表单显示字段? - How can I make the HTML form display fields based on specific condition? 在Javascript中,我如何发出警报并根据表单内容修改html - In Javascript how can I make an Alert and modify html based on the contents of a form
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM