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?
[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+" "; } </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]
Help @jjhatz spread the word by sharing this article on Twitter...