Should be easy - Variable to email?

L

Larry L

This is a novice question, but I'm stumped. I have a variable with a bunch
of text assigned to it. Now I want to email the value of the variable. I
have a simple form that asks for their name and emails that, but how do I
add the variable result?

Thanks much,
Larry
 
K

kaeli

This is a novice question, but I'm stumped. I have a variable with a bunch
of text assigned to it. Now I want to email the value of the variable. I
have a simple form that asks for their name and emails that, but how do I
add the variable result?

If you are mailing server-side, as is most stable and robust for internet
applications, you do it with the server-side language of choice.

If you are using mailto as a form action, it's not good for this. You would
basically have to have a javascript handler for the form that writes the
value of the variable to a hidden form field and then submits the form, then
when the form is mailed, you'll get the value in there. Obviously it wouldn't
work for users without script.

There are a lot of possible problems with using mailto for internet apps, so
if you are, you might want to look in the archives and decide if it's really
want you want to use.

--
--
~kaeli~
Synonym: the word you use in place of a word you can't
spell.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace
 
G

Grant Wagner

Larry said:
This is a novice question, but I'm stumped. I have a variable with a bunch
of text assigned to it. Now I want to email the value of the variable. I
have a simple form that asks for their name and emails that, but how do I
add the variable result?

Thanks much,
Larry

<form method="POST" action="sendmail.cgi">
<script type="text/javascript">
document.write('<input type="hidden" name="stuff" value="' + yourVariable +
'">');
</script>
<input type="submit" value="Send Stuff">
</form>

If yourVariable may contain quotation marks or new line characters, you must
either remove them, replace them, or escape them.
 
L

Larry L

<form method="POST" action="sendmail.cgi">
<script type="text/javascript">
document.write('<input type="hidden" name="stuff" value="' + yourVariable +
'">');
</script>
<input type="submit" value="Send Stuff">
</form>

If yourVariable may contain quotation marks or new line characters, you must
either remove them, replace them, or escape them.

Grant,

Well it took me this long to understand what is happening in my page. Your
script, of course, works perfectly by itself. However, on my page I do
several things, requiring user input, to create the variable that I then
want to send via formmail. As I understand it, your code executes as the
page loads, and at that point the variable is empty. I have a form
that runs some other javascript that creates the value (a string) in the
variable, then I have a simple second form with a button you click to
display it, then a third form that asks for yor name, and sends the
name and string via email. The first 2 are working. Any further
suggestions for the 3rd?

Thanks much,
Larry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top