You need to sign in to do that
Don't have an account?
Jonathan Bernd 31
best way to create onClick send email to an input field in salesforce1 mobile
Hi folks
Not great at javascript. Also newbie with Salesforce1 mobile. Here's my problem. Trying to create an onClick button that passes the contents of an input field (entered on a custom visualforce SF1 page) as the 'mailto' email address. I want to add a set subject line and body and then send this email on the click of a button on my custom mobile vf page.
I have created a link in js which does everything EXCEPT bring in the email address from the input field. I may be using the wrong syntax for a random input field but here's what I'm using <input type="text" id="email"/>. I want to get this into a variable that I can use for the 'to' address.
E.g.
As you can see I've made this a link in the interim that 'works' for what it does, but does not answer my missing enterable email problem.
What I really want to do then is have an onClick button that will activate the above instead of a link.
If you can help me with best practices for this it will go a long way as I can use the principles to apply to my further investigation and development.
Thanks
Not great at javascript. Also newbie with Salesforce1 mobile. Here's my problem. Trying to create an onClick button that passes the contents of an input field (entered on a custom visualforce SF1 page) as the 'mailto' email address. I want to add a set subject line and body and then send this email on the click of a button on my custom mobile vf page.
I have created a link in js which does everything EXCEPT bring in the email address from the input field. I may be using the wrong syntax for a random input field but here's what I'm using <input type="text" id="email"/>. I want to get this into a variable that I can use for the 'to' address.
E.g.
var email (here's where I need my incoming email from the input field) var subject = ('My permanent subject line'); var body = ('My permanent body contents'); document.write('<a href="mailto:' + email + '?subject=' +subject+ '&body=' +body+ '">' + 'Click here to send email as well' + '<'+'/a>');
As you can see I've made this a link in the interim that 'works' for what it does, but does not answer my missing enterable email problem.
What I really want to do then is have an onClick button that will activate the above instead of a link.
If you can help me with best practices for this it will go a long way as I can use the principles to apply to my further investigation and development.
Thanks
you can code something like this :
<body>
E-mail <input type="email" id="emailID" />
<button onclick="sendemail()"> Submit </button>
<script>
function sendemail()
{
var email = document.getElementById("emailID").value;
var subject = ('My permanent subject line');
var body = ('My permanent body contents');
document.write('<a href="mailto:' + email + '?subject=' +subject+ '&body=' +body+ '">' + 'Click here to send email as well' + '<'+'/a>');
}
</script>
</body>
Explanation :
emailID : is ID of input field which is used in Java Script code to assign value of email variable using document.getElementById( " ").value function
sendemail(): is a Java Script function which gets executed when user clicks on submit button.
Please let me know in case you have any more issues.