smitty62
asked on
html generated email...body won't work.
The body of this email is not working. What am I doing wrong?
Email: <input type="text" id="email"></input><br>
Subject: <input type="text" id="subject"></input><br>
Body: <input type="text" id="comment"></input><br>
<button onclick="myFunction()">Review Before Sending</button>
<p id="demo"></p>
<script>
function myFunction() {
var input = document.getElementById('email');
email = input.value;
var input = document.getElementById('subject');
subject = input.value;
var input = document.getElementById('comment');
subject = input.value;
window.location.href = "mailto:" + email + "?subject=" + subject + "&body=" + comment;
}
</script>
you email client may not allow to run javascript which should be the case for security purpose
ASKER
The code below works, but I need to get the body (input fields) inserted. How do I create a string field variable then use that variable in the "action=" option.
<form style="text-align:left; margin:5%" action="mailto:doi.webmaster@illinois.gov?subject=Test_Mail" method="post" enctype="text/plain">
Name: <input type="text" name="name"><br>
org: <input type="text" name="org"><br>
Comment: <input type="text" name="comment" size="50"><br><br>
<input type="text" name="string"><br>
<input type="submit" value="Send"> <input type="reset" value="Reset">
</form>
ASKER
okay, I've been working on this, and so far this is what I have, however the variable is not be recognized by the "action="
I've seen other code snippets out there using a variable in this way, but I can't get it to work.
I've seen other code snippets out there using a variable in this way, but I can't get it to work.
<form style="text-align:left; margin:5%" action="stringer" method="post" enctype="text/plain">
Name: <input type="text" name="name"><br>
Organization: <input type="text" name="org"><br>
Comment: <input type="text" name="comment" size="50"><br><br>
<input type="text" name="string"><br>
<input type="submit" value="Send"> <input type="reset" value="Reset">
</form>
<script>
function myFunction() {
var input = document.getElementById('name');
email = input.value;
var input = document.getElementById('org');
subject = input.value;
var input = document.getElementById('comment');
subject = input.value;
var stringer = "mailto:doi.webmaster@illinois.gov?subject=Test_Mail&body=" + name + " - " + org + " - " + comment;
}
</script>
ASKER
This is working, however a null is getting inserted into the variables for some reason.
<script type="text/javascript">
function myFunction() {
alert("alert message1");
var name1 = document.getElementById('name');
alert(name1);
var org1 = document.getElementById('org');
alert(org1);
var comment1 = document.getElementById('comment');
alert(comment1);
window.location.href = "mailto:doi.webmaster@illinois.gov?subject=Test_Mail&body=" + name1 + " - " + org1 + " - " + comment1;
}
</script>
<form style="text-align:left; margin:5%" action="stringer" method="post" enctype="text/plain">
Name: <input type="text" name="name"><br>
Organization: <input type="text" name="org"><br>
Comment: <input type="text" name="comment" size="50"><br><br>
<button onClick="myFunction()">Review your comment</button>
<!-- <input type="submit" value="Send"> <input type="reset" value="Reset"> -->
</form>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I think your right about that. I think that's for .net not html. I was hoping to use fill in boxes then setup in a form, then with javascipt move that information in to the href mailto: statement using a variable, however, the user decided on something else and we will be using survey monkey to collect the data instead.
Thank you for help.
Thank you for help.
ASKER
thank you for your help.