gpt4 book ai didi

javascript - 如何发送带有用户输入地址的 HTML 电子邮件?

转载 作者:行者123 更新时间:2023-11-28 16:11:38 26 4
gpt4 key购买 nike

我正在设计一个应用程序,并且有一个电子邮件页面。用户输入姓名、电子邮件地址和消息,然后单击“提交”。这可行,但我不知道如何使用户的输入出现在电子邮件中。这是到目前为止的代码;

<form id="contacts-form" action="mailto:megan.sime@idoxgroup.com">
<ul class = "rounded">
<li style = "color: #FFFFFF">Full Name:<input type="text" placeholder = "J. Doe" name = "signature" id = 'signature' /></li>
<li style = "color: #FFFFFF">E-mail:<input type="text" placeholder = "www.example@examplemail.com" name = "address" id = 'address' /></li>
<li style = "color: #FFFFFF">Message:<input type = "text" placeholder = "Message" name = "message" id = 'message' /></li>

<a href="mailto:address?subject=subject&body=message" class="button">Submit</a>
</ul>
</form>

有谁知道如何更改代码以允许用户输入进入电子邮件?非常感谢 x

最佳答案

尝试编写这样的函数:

function sendEmail(){
var addr = document.getElementById('address').value;
var sig = document.getElementById('signature').value;
var msg= document.getElementById('message').value;

//concatenate to string to build URL
var url = "mailto:" + .... + addr + ...;
location.href = url; //(might want to use window.location or something else here)
}

然后将链接更改为:

<a href="javasctipt:void(0)" onclick="javascript:sendEmail()" class="button">Submit</a>

关于javascript - 如何发送带有用户输入地址的 HTML 电子邮件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12724179/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com