Situation: School council wants to funnel all contact through a single form. Instead of providing differing mailto: links on each page (mailto:fundraising.committee@school.tld), all pages will link back to a single form where visitor is expected to select the intended recipient. i.e. Sometimes the visitor will not know who to select on the form whereas a mailto: link would be obvious.
So, instead of linking to just
http://school.tld/contactcouncil.htm
The links will read like this:
http://school.tld/contactcouncil.htm?for=fundraising
This page contactcouncil.htm contains an ordinary form designed for formmail, it's important to name the form and be sure it matches in the script
<form name="form1" method="post" action...
and using aliases for the recipients:
Code: Select all
Intended Recipient of your message:
<select name="recipient">
<option value="general">I don't know</option>
<option value="volunteering">Volunteer Co-ordinator</option>
<option value="executives">Council Executives</option>
<option value="fundraising">Fundraising Committee</option>
</select>
Add this to the head:
Code: Select all
<script language="JavaScript">
<!-- Hide from incompatible browsers
function getRecip() {
var query= window.location.search.substring(1);
var pattern = /for=(\w+)/;
if (pattern.test(query)) {
var vars= query.split("&");
for (var i=0;i<vars.length;i++) {
var pair=vars[i].split("=");
if (pair[0]=="for") { var recip = pair[1]; break; }
}
} else { var recip = 'general'; }
for ( var j=0;j<document.form1.recipient.options.length;j++) {
if (document.form1.recipient.options[j].value==recip) {
document.form1.recipient.selectedIndex = j;
break;
}
}
}
//-->
</script>
and this to the body tag
<Body onload="getRecip();" ...
What this will do is automatically select the appropriate recipient in the dropdown depending on what value for "for=" is in the query string of the URL, defaulting to 'general' if none is specified or no match is found from the recipient list.