...

View Full Version : form mailto with checkboxes?



leaflover
12-08-2009, 10:56 PM
I have a question and I'm hoping someone may have some suggestions on how to solve.

I found a script on this forum that does almost what I want from this thread:
http://codingforums.com/showthread.php?t=184011 (thank you Philip M!)

Instead of a dropdown, I'd like to have a list of names using check boxes, so that you have the option to send an email to one or all of the people. When you choose your selections and click submit, an outlook email will pop up with your selections in the to: field.

Is this possible?

Here's the solutuin using a drop down, this works (and works well), but doesn't quite do what I need :

<form name="Contact_Us" id="contact" method="post" enctype="text/plain" onsubmit = "getEml()">
<fieldset id="selection">
Who would you would like to email:
<select name = "sel">
<option value="email1@email.com" >email 1</option>
<option value="email2@email.com" >email 2</option>
<option value="email3@email.com" >email 3</option>
</select>
<input type = "submit" value = "Submit the form">
</form>

<script type = "text/javascript">
function getEml() {
var emailaddress = document.Contact_Us.sel.value;
window.location = "mailto:" + emailaddress;
}

</script>

Is there a way to use checkboxes but to do the same thing?

<INPUT TYPE=CHECKBOX NAME="name1@email.com">name 1<BR>
<INPUT TYPE=CHECKBOX NAME="name2@email.com">name 2<BR>
<INPUT TYPE=CHECKBOX NAME="name3@email.com">name 3<BR>

Philip M
12-09-2009, 09:30 AM
"Once more unto the breach, dear friends, once more" - Shakespeare, Henry V Act III.


<form name="Contact_Us" id="contact" method="post" enctype="text/plain" onsubmit = "getEml()">

Who would you would like to email:<br>
<input type = "checkbox" name = "cbox" value="name1@email.com">name 1<br>
<input type = "checkbox" name = "cbox" value="name2@email.com">name 2<br>
<input type = "checkbox" name = "cbox" value="name3@email.com">name 3<br>
<input type = "submit" value = "Submit the form">
</form>

<script type = "text/javascript">
function getEml() {
var emailaddress = "";
var boxes = document.Contact_Us.cbox.length;
for (i = 0; i < boxes; i++) {
if (document.Contact_Us.cbox[i].checked) {
emailaddress= emailaddress + document.Contact_Us.cbox[i].value;
emailaddress += ";" ;
}
}
if (emailaddress == "") {
alert ("Please check one or more boxes!");
return false
}
window.location = "mailto:" + emailaddress;
}

</script>

I take it that you realise that putting un-encrypted or un-obfuscated email adrresses in a web page exposes those recipients to a torrent of spam.


"I used to think I was poor. Then they told me I wasn't poor, I was needy. Then they told me it was self-defeating to think of myself as needy. I was deprived. (Oh not deprived but rather underprivileged.) Then they told me that underprivileged was overused. I was disadvantaged. I still don't have a dime. But, I have a great vocabulary." - Jules Feiffer, cartoonist.

leaflover
12-09-2009, 07:35 PM
I do realize it would open up a world of trouble for these users if this was an open website. But it's internal to a company, behind a firewall, with no access from any external users whatsoever. So I think it's safe from the perils of spam.

Thank you!


“Appreciation is a wonderful thing. It makes what is excellent in others belong to us as well.” - Voltaire



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum