使用javascript或jquery通过get将数据从一个表单推送到另一个表单

使用javascript或jquery通过get将数据从一个表单推送到另一个表单,javascript,php,html,magento,get,Javascript,Php,Html,Magento,Get,我在我的网站上有一个用php构建的电子邮件初始注册框。我使用的是magento,因此我不能简单地将变量从下一页的“进入电子邮件”字段中回显。这是我目前唯一习惯这样做的方式 <form action="<?php echo $this->getUrl('email_preferences') ?>" method="get" id="newsletter-validate-detail" class="footerNewsletter"> <label

我在我的网站上有一个用php构建的电子邮件初始注册框。我使用的是magento,因此我不能简单地将变量从下一页的“进入电子邮件”字段中回显。这是我目前唯一习惯这样做的方式

<form action="<?php echo $this->getUrl('email_preferences') ?>" method="get" id="newsletter-validate-detail" class="footerNewsletter">
    <label for="newsletter" class="footerHeads"><?php echo $this->__('Connect With US') ?></label>
    <div class="inputTextContainer">
        <input name="email" type="text" id="newsletter" placeholder="<?php echo $this->__('enter email for specials and updates!') ?>"
               title="<?php echo $this->__('Enter email for specials and updates!') ?>" class="required-entry validate-email">
        <i class="icon-mail"></i>
    </div>
    <input type="hidden" name="source" value="nt" />
    <button type="submit" class="button" style="display:none;" title="<?php echo $this->__('Subscribe') ?>"><span><span><?php echo $this->__('Subscribe') ?></span></span></button>
</form>
<script type="text/javascript">
//<![CDATA[
    var newsletterSubscriberFormDetail = new VarienForm('newsletter-validate-detail');
//]]>
</script>
试试使用,它会让生活更轻松。假设您的页面URL如下:
www.example.com/page.php?电子邮件=me@email.com

<script type="text/javascript">
$(function() {
    $('input[name="email"]').val(window.location.search.replace('?email=', ''));
});
</script>

$(函数(){
$('input[name=“email”]').val(window.location.search.replace('?email=','');
});
如果您正在访问
www.example.com/page.php?电子邮件=you@domain.com
然后“名称”输入字段将获得值“you@domain.com“


示例fidde:(为了演示,不得不用静态字符串替换
window.location.search

非常感谢@DanLNo problem,很高兴能提供帮助。我在.com之后有了更多的动态链接。我怎样才能把它剪掉。。在.com之后的任何事情&source=nt我想这些第二个引号有什么关系?(“?email=”,“”)在.replace(“?email=”,“”)之后添加.replace(“%40”,“@”)
<script type="text/javascript">
document.getElementById("email").innerhtml = window.location.search;
</script>
<script type="text/javascript">
$(function() {
    $('input[name="email"]').val(window.location.search.replace('?email=', ''));
});
</script>