View Full Version : email subject composed

01-21-2003, 08:43 AM
I知 just beginning with JS and am already fanatic. But due to lack of experience I have a problem with pre-defining the subjectrule in an email.

What I知 trying to do is the following ..

In html you use this code to open an e-mail with predefined subject. (The choise to whom is open, because here I値l use the selection that is provided by outlook once the e-mail opens. I make a selection out of an adressbook.).

<a href="mailto:?subject= ???????????????????????????????">IMAGE</a>

??????????????????????????????? is composed of the following elements:

XXXXXX - and ?????? ?????? and - MMMMMMMMMMM ( ).

XXXXXX - and - MMMMMMMMMMM ( ). are already in the subject rule.

XXXXXX - at the beginning of the subjectrule and - MMMMMMMMMMM ( ) at the end.

?????? ?????? is a selection out of a list (can be one word or a sentence). This selection is enclosed by XXXXXX - and - MMMMMMMMMMM ( ) .

What should I do so that everything comes together when the e-mail opens to indicate the recipient?

Something like following code (?????)

<a href="mailto:?subject= XXXXXX - {select a word or sentence out of a list} - MMMMMMMMMMM ( ) ">IMAGE</a>

Which script should I use to select a word or sentence out of a list and when selected, this selection should place itself between the 2 already defined XXXXXX - and - MMMMMMMMMMM ().

Should it be better to use PHP to obtain that list from the server and then use JavaScript? Or is this something stupid to mention???

Is there please somebody who can help me??

Thanks a lot in advance.

Jef Gees
e-mail: jefgees@westbrabant.net

01-21-2003, 01:31 PM
What you are trying to acheive ideally needs to be done by reloading the page so that the values can be hard-coded into the HTML at run time. Having said that, you can achieve a similar effect using DHTML to write your mailto link into a <div> without reloading the page. Bear in mind that this will only work in browsers such as IE5, NS6 and upwards. You could also add a little patch to get it to work in IE4 if needed. Have a play with my example, I hope it furthers your understanding.

<title>Changing a mailto: link using DHTML</title>
function changeMailto(i){
mailtoString = "<a href=\"mailto:person@domain.com?subject=XXXXXX - "+i+" - MMMMMMMMMMM ( )\">IMAGE</a>";
document.getElementById('test').innerHTML = mailtoString;

<select onchange="changeMailto(this.options[this.selectedIndex].value)">
<option value="apples">apples</option>
<option value="oranges">oranges</option>
<option value="bananas">bananas</option>

<br />

<div name="test" id="test"></div>