如何从 jQuery 插件中提取值并将其设置为 PHP 变量?
我正在使用名为 Stepy 的 jQuery 插件,允许用户完成 10 步表单。
示例表单: http://jsfiddle.net/wvkfn/
我的网站已设置,以便用户可以离开表单在“步骤”的中间,为了完成其他任务,我想要一个变量集,这样当他们完成任务时,它会将他们带回他们所在的最后一步。
有没有办法从插件中提取“当前”步骤的值?我的第一个想法是,该插件在标题上放置一个名为 current-step
的类,并从设置了该类的标题文本中提取数字值。
然后我想将其设置为 PHP 变量,这样我就可以将任务链接设置为类似 http://www.example.com/task.php?step=3。
关于如何解决这个问题有什么想法吗?
I am using a jQuery plugin called Stepy, to allow users to complete a 10-step form.
Sample form: http://jsfiddle.net/wvkfn/
My site is setup so the user can leave the form in the middle of a 'step', in order to complete other tasks, and I'd like to have a variable set, so that when they complete the task, it takes them back to the last step they were on.
Is there a way to pull the value of the 'current' step from the plugin? My first thought was that the plugin places a class called current-step
on the title, and pull the number value from the title text that has that class set.
I'd then want to set that as a PHP variable, so I could set the task link to something like http://www.example.com/task.php?step=3.
Any ideas on how to go about this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 stepy 提供的“选择”选项在选择选项卡时注册回调。在回调中,使用异步 POST 到服务器来存储当前选定的选项卡。
样本:
Use the 'select' option stepy offers to register a callback when a tab is selected. In the callback use an asynchronous POST to your server to store the currently selected tab.
Sample:
简单的解决方案是为当前步骤存储一个
cookie
,或者您可以为每个步骤使用anchors
,如步骤 1mysite.com/task.php#tsep1
并从URL
中提取值The simple solution would be to store a
cookie
for current step OR you can useanchors
for each step like for step 1mysite.com/task.php#tsep1
and pull the value fromURL