问题描述
我正在处理HTML表单,我想在单击提交"按钮后实现,然后转到确认页面.确认页面从表单页面获取数据.
I'm working on a HTML form, I'd like to achieve once the submit button hit, then goes to a confirmation page. The confirmation page get the data from form page.
例如,由于我的表单验证被jQuery使用,因此我的变量名是VISITORNAME
如何使构造页面显示谢谢您VISITORNAME
"
As my form validation is used by jQuery, for example I have a variable name is VISITORNAME
How to make the conformation page shows "THANK YOU VISITORNAME
"
我做了研究,找不到简单易行的方法.
I did research, could not find a simple easy way to do it.
推荐答案
您有很多方法可以做到这一点,一种方法是在提交表单时在url中添加一些内容,并在另一页中使用js进行阅读(这不会涉及服务器端编码)
you have many ways to do that, one is to add something to the url when the form is submitted and read with js in the other page (this does not involve server side coding)
$(form).submit(function() {
$(this).action += '#visitorname=whatever'
});
然后以表格的形式从URL获取访客名称
Then in the form you can get the visitorname from the url
var name = window.location.href.replace(/^.*#visitorname=/, "")
这篇关于jQuery简单数据传递HTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!