A useful feature in many websites allows users to click on a button and send an email, automatically passing information from the screen as data (To, Subject, Message, and so on) into the email itself.
A function called SENDEMAIL is included in the default YSCRIPT.JS file, which has five arguments (parameters): TO, CC, BCC, SUBJECT, and BODY. This function performs all the processing necessary to create an email.
Use the following code to create a button that sends e-mail:
<INPUT TYPE=”BUTTON” VALUE=”button-value” onclick=”SENDEMAIL(to-value, cc-value, bcc-value, subject-value, body-value)”>
To summarize:
Notes:
<FORM...>
...
<INPUT TYPE=”TEXT” NAME=”COMMENTS” VALUE=” ” SIZE=”100”>
<INPUT TYPE=”BUTTON” VALUE=”Send us your comments” onclick=”SENDEMAIL('firstname.lastname@companyname.com' , '' , '' , 'My comments on your website' , this.form.COMMENTS.value)”
...
</FORM>
Clicking the Send us an email button opens an e-mail window with:
In general, you can use any field value, by specifying it as:
this.form.field-name.value
Where field-name is the name of another field on the same form
| Copyright © 2011 CA. All rights reserved. | Tell Technical Publications how we can improve this information |