简体   繁体   English

在提交时将JS变量传递给HTML表单-Mailchimp嵌入表单

[英]Pass JS variable to HTML form onsubmit - Mailchimp embed form

I have a form that I am trying to pass a JavaScript variable into. 我有一种试图将JavaScript变量传递到的形式。 The custom hidden field works, but nothing gets passed into it... is there something wrong with the onsubmit code? 自定义隐藏字段有效,但是没有传递任何内容……onsubmit代码是否有问题?

Embedded form code: 嵌入式表格代码:

<input type="email" value="" name="EMAIL" class="email" id="mce-EMAIL" placeholder="email" required>
<input type="hidden" name="REFERID" id="MERGE1" value="">

Here is the JS Code later in the page: 这是页面后面的JS代码:

<script type="text/javascript">

function addref() {
    var urlref = (document.url);
    var refcode = urlref.substring(urlref.indexOf "ref" +4 != urlref.length);

            document.mc-embedded-subscribe-form.MERGE1.value = refcode;
}
    </script>

尝试使用:

document.getElementById("MERGE1").value = refcode;

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM