admin管理员组文章数量:1391937
I have an app i am designing and there is a page for emails. The user inputs their name, email address and message and then clicks 'submit'. this works, but i don't know how to make the user's input be on the email. this is the code so far;
<form id="contacts-form" action="mailto:[email protected]">
<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 = "[email protected]" 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>
does anyone know how to change the code to allow the user input to go onto the email? Thanks a lot in advance x
I have an app i am designing and there is a page for emails. The user inputs their name, email address and message and then clicks 'submit'. this works, but i don't know how to make the user's input be on the email. this is the code so far;
<form id="contacts-form" action="mailto:[email protected]">
<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 = "[email protected]" 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>
does anyone know how to change the code to allow the user input to go onto the email? Thanks a lot in advance x
Share Improve this question edited Oct 4, 2012 at 9:28 RB. 37.3k13 gold badges101 silver badges136 bronze badges asked Oct 4, 2012 at 9:25 user1703470user17034703 Answers
Reset to default 4Try writing a function like this:
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)
}
And then change your link to:
<a href="javasctipt:void(0)" onclick="javascript:sendEmail()" class="button">Submit</a>
You'll have to use javascript to obtain the input values. With onclick="javascript:window.location='putURLhere'"
you can imitate a link. What's left now is to create a URL that contains your values, which you can get with document.getElementById(id).value
. With +
you can concatenate them.
Example:
<a onclick="javascript:window.location='mailto:?subject=Message from '+document.getElementById('address').value+'&body='+document.getElementById('message').value">Submit</a>
I hope this helps!
Not pletely sure what you are asking by "allow the user input to go onto the email", but using document.getElementById('signature').value
will return the input's value. You can then include that in your post/get.
本文标签: javascriptHow do I send an email with HTML with an address the user inputsStack Overflow
版权声明:本文标题:javascript - How do I send an email with HTML with an address the user inputs? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744719791a2621626.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论