如何获取在表单中输入的电子邮件地址,并在不同页面上的另一个表单中自动填写该地址?

发布于 2024-12-11 20:58:05 字数 515 浏览 0 评论 0原文

好吧,我已经搜索了这个网站,但似乎找不到我要找的东西。我对任何类型的编程都是全新的,所以请耐心等待。 :)

我有一个网站,底部有一个“输入您的电子邮件地址以注册我们的时事通讯”的表格。它只有一个字段和一个“提交”按钮。此提交按钮会将您带到另一个页面,我需要该页面在电子邮件地址区域中自动填写电子邮件地址,然后该人可以选择他们的其余首选项。

有人可以向我解释一下如何执行此操作或将我指向另一个帖子或网站或其他内容吗?也许我的搜索条件不正确。任何帮助将非常感激。谢谢。

更新:感谢大家的超级快速和有用的回答!在您的帮助下,我成功解决了我的问题。我对建议的内容做了一些研究(就像我说的,我是一个完全的初学者......),我发现了这个网站,给出了详细的说明! -> 使用 JavaScript 预填写和多页表单

Ok, I have searched this site and I can't seem to find what I'm looking for. I am completely new to any kind of programming, so be patient please. :)

I have a website, at the bottom will be a "enter your email address to sign up for our newsletters" form. It will only have the one field, and a "submit" button. This submit button will take you to another page and I need the page to have auto-filled in the email address in the email address area, and then the person can choose the rest of their preferences.

Can someone please explain to me how to do this or point me to another post or site or something. Perhaps my search criteria is incorrect. Any help would be very much appreciated. Thanks.

UPDATE: Thank you everyone for your super fast and helpful answers!! I have, with your help, successfully resolved my question. I did some research on what was suggested (like I said, I'm a complete beginner...) and I came across this website, giving detailed instructions! -> Pre-Fill and Multi-Page Forms with JavaScript

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

放低过去 2024-12-18 20:58:05

在 Web 应用程序的两个页面之间传输信息是一个常见问题。由于您已将其标记为 Javascript,因此您可能需要考虑使用 HTTP“GET”方法定位第二个页面,我们将其称为 pagetwo.html

<form id="firstPageEmailForm" action="pagetwo.html" method="get">
    <input type="text" name="emailaddress" />
    <input type="submit" />
</form>

提交后,信息将传递到 pagetwo.html,如下所示:[电子邮件受保护]

您可以访问该信息使用 javascript 对象 window.location.href。只需解析出 emailaddress 字段,并在 pagetwo.html 上的新表单中设置输入字段的 value 属性即可。

Transferring information between two pages on a web application is a common problem. Since you've tagged this as Javascript, you might want to consider targeting your second page, let's call it pagetwo.html, with the HTTP 'GET' method.

<form id="firstPageEmailForm" action="pagetwo.html" method="get">
    <input type="text" name="emailaddress" />
    <input type="submit" />
</form>

On submit, the information will be passed to pagetwo.html like this: [email protected]

You can get at this information using the javascript object window.location.href. Just parse out the emailaddress field and set the value attribute of the input field in the new form on pagetwo.html.

佼人 2024-12-18 20:58:05

您应该将电子邮件字段放在输入元素中,并使用 FORMaction 指向另一个页面 - 您可以在其中请求: request.form[....

you should put the email field in a input element and use the action of the FORM to point to another page - where you can request : request.form[....

鲜肉鲜肉永远不皱 2024-12-18 20:58:05

由于您只具体提到了 javascript,我假设您正在尝试执行此客户端操作。在这种情况下,您只需设置一个 cookie,然后检索它以填充后续表单上的字段。

当您使用 jquery 时,请参阅 Cookie 插件

As you only specifically mention javascript, I assume you're trying to do this client side. In which case, you just need to set a cookie, and then retrieve it to populate the field on the subsequent forms.

As you're using jquery, see the Cookie plugin.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文