/    Sign up×
Community /Pin to ProfileBookmark

e-mail address choices in forms

I have a page on my intranet for employees to request vacation time. Different employees must make their requests to different people. Is there a way to change the ACTION:mailto: value by using <SELECT> or radio buttons?

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@MjhLkwdOct 13.2005 — [CODE]<HTML>
<Head>
<Script type="text/javascript">

function sendMail(isForm){

var isBody = "";
var recipient = isForm.sendTo.value;
var isSubject = "Form Data";
isBody = "Name: " + isForm.personal.value +"%0D%0A";
isBody += "Address: " + isForm.address.value +"%0D%0A";
isBody += "City: " + isForm.city.value +"%0D%0A";
isBody += "State: " + isForm.state.value +"%0D%0A";
isBody += "Zip: " + isForm.zip.value;
document.forms.Send.action = "mailto:"+recipient+"?subject="+isSubject+"&body="+isBody+"&nbsp";
}

</Script>
</Head>
<Body>
<Form name='Form1'>
Name <input type='text' name='personal' value="John Doe" size=25><br>
Address <input type='text' name='address' value="123 Main Street" size=30><br>
City <input type='text' name='city' value="Springfield" size=15> State <input type='text' name='state' value="OH" size=2><br>
Zip Code <input type='text' name='zip' value="12345" size=4><br>
<select name='sendTo'>
<option value = ""> Recipient </option>
<option value="[email protected]"> Bob </option>
<option value="[email protected]"> Alice </option>
<option value="[email protected]"> Ted </option>
</select>
</Form>
<Form name='Send' action=''>
<input type="submit" value="Send by Email" onclick="sendMail(document.Form1)">
</Form>
</Body>
</HTML>[/CODE]
×

Success!

Help @jjhatz spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.29,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...