简体   繁体   English

带有条件的Formmail.com复选框

[英]Formmail.com with conditions on checkboxes

Using this service (http://www.formmail.com) on a form and Ive run into a bit of a problem that after extensive google searching has not given me an answer. Ive在表单上使用此服务(http://www.formmail.com)和Ive遇到了一个问题,经过大量的google搜索后,我没有找到答案。 I want to add who gets an email if a check box has been checked. 如果要选中一个复选框,我想添加谁会收到电子邮件。 Ive tried a few JS and PHP solutions and nothing seems to work. 我已经尝试了一些JS和PHP解决方案,但似乎没有任何效果。 The main problem seems to be how the service does the email proccessing by needing <input type="hidden" name="recipient" value="X"> in the form to determine who to email. 主要问题似乎在于该服务如何通过需要表单中的<input type="hidden" name="recipient" value="X">来确定向谁发送电子邮件的方式来进行电子邮件处理。

Including the checkbox code although its nothing special 包括复选框代码,尽管没什么特别的

<form method="POST" action="http://fp1.formmail.com/cgi-bin/fm192"> 
<input name="Checkbox1" type="checkbox" id="Checkbox1" value="Yes"/> 
<input type="submit" name="formSubmit" value="Submit"/>
<input type="hidden" name="_pid" value="XXXX">
<input type="hidden" name="_fid" value="XXXX">
<input type="hidden" name="recipient" value="1">
</form>

edit 编辑

It send to email 1 now. 现在发送到电子邮件1。 I want it to also send to email 2 if the checkbox is checked. 如果选中此复选框,我希望它也发送到电子邮件2。

Answer. 回答。 Found out the answer. 找出答案。 Stupid thing wont let me self answer however. 愚蠢的事情不会让我自己回答。

<script type="text/javascript" language="JavaScript">

function oncheckboxclick() {
    var c = document.getElementById("checkbox1");
    var d = document.getElementById("email");
    if (c.checked) {
        c.checked == true;
        d.setAttribute("value", "2");
    }
}

</script>

<input name="Box 1" type="checkbox" id="checkbox1" value="Yes" onclick="oncheckboxclick();"/>

<input type="hidden" name="recipient" id="email">

Thanks to whoever put up an answer than retracted it. 多亏了谁提出了答案,才收回了答案。 Gave me enough breadcrumbs to go on. 给了我足够的面包屑以继续下去。

Without knowing what they're doing on their end to process the forms, I'd suggest doing this in PHP or some other programming language. 我不知道他们在处理表单方面会做什么,我建议使用PHP或其他某种编程语言来完成此操作。 PHP:Mailer is really well documented and adding something like PHP:Mailer确实有据可查,并添加了类似内容

if ($checkbox == 'YES") { add new recipient here} 如果($ checkbox =='YES“){在此处添加新收件人}

else { proceed as normal} 其他{照常进行}

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

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