Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

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?

You are here: irt.org | FAQ | JavaScript | Email | Q1016 [ previous next ]

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?'

©2018 Martin Webb