Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

Q1016 How can I send an email using a form with a predefined subject field, a user defined email address and a footer with a URL?

irt.org | Knowledge Base | JavaScript | Email | Q1016 [ previous next ]

Q1016 How can I send an email using a form with a predefined subject field, a user defined email address and a footer with a URL?

YMMV depending on the browser and email client, but try:

<script language="JavaScript"><!--
function update(what) {
    what.action = 'mailto:' + document.hiddenForm.emailAddress.value +
                  '?SUBJECT=' + document.hiddenForm.subjectLine.value;
    what.elements[' '].value += '\n\n';
}
//--></script>

<form name="hiddenForm" onSubmit="return false">
Email Address: <input type="text" name="emailAddress">
<input type="hidden" name="subjectLine" value="Hello World">
</form>

<form name="emailForm" method="post" enctype="text/plain">
Message Body: <textarea name=" "></textarea>
<input type="submit" onClick="update(this.form)">
<input type="hidden" name="Internet Related Technologies - <URL" value="http://www.irt.org/>">
</form>

Which sends an email message looking like:

Subject: 
             Hello World
        Date: 
             Mon, 05 Apr 1999 19:42:56 +0000
        From: 
             Martin Webb <martin@irt.org>
 Organization: 
             irt.org - http://www.irt.org
          To: 
             martin@irt.org



 =this is a test



Internet Related Technologies - <URL=http://www.irt.org/>

You cannot avoid the "=" sign. Although you could make it appear as part of the message with something like:

<script language="JavaScript"><!--
function update(what) {
    what.action = 'mailto:' + document.hiddenForm.emailAddress.value +
                  '?SUBJECT=' + document.hiddenForm.subjectLine.value;
    what.elements[' '].value = ' Subject Heading =\n\n' + what.elements[' '].value + '\n\n';
}
//--></script>

<form name="hiddenForm" onSubmit="return false">
Email Address: <input type="text" name="emailAddress">
<input type="hidden" name="subjectLine" value="Hello World">
</form>

<form name="emailForm" method="post" enctype="text/plain">
Message Body: <textarea name=" "></textarea>
<input type="submit" onClick="update(this.form)">
<input type="hidden" name="Internet Related Technologies - <URL" value="http://www.irt.org/>">
</form>

which appears as:

Subject: 
             Hello World
        Date: 
             Mon, 05 Apr 1999 19:47:14 +0000
        From: 
             Martin Webb <martin@irt.org>
 Organization: 
             irt.org - http://www.irt.org
          To: 
             martin@irt.org



 = Subject Heading =

this is a test



Internet Related Technologies - <URL=http://www.irt.org/>

Feedback on 'Q1016 How can I send an email using a form with a predefined subject field, a user defined email address and a footer with a URL?'


Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.